/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.ui.rich.full;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ListIterator;
import java.util.ResourceBundle;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.Position;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;

import br.ufmg.dees.insane.commons.InsaneProperties;
import br.ufmg.dees.insane.commons.command.Command;
import br.ufmg.dees.insane.commons.command.CommandHolder;
import br.ufmg.dees.insane.commons.command.RedoCommand;
import br.ufmg.dees.insane.commons.command.UndoCommand;
import br.ufmg.dees.insane.commons.controller.Controller;
import br.ufmg.dees.insane.commons.view.CmdButton;
import br.ufmg.dees.insane.commons.view.CmdCheckBoxMenu;
import br.ufmg.dees.insane.commons.view.CmdMenu;
import br.ufmg.dees.insane.commons.view.CmdToggleButton;
import br.ufmg.dees.insane.commons.view.Console;
import br.ufmg.dees.insane.commons.view.ConsoleHandler;
import br.ufmg.dees.insane.commons.view.DrawingArea;
import br.ufmg.dees.insane.commons.view.ImageDA;
import br.ufmg.dees.insane.commons.view.InternalInterface;
import br.ufmg.dees.insane.model.Model;
import br.ufmg.dees.insane.model.ModelState;
import br.ufmg.dees.insane.model.disc.element.Element;
import br.ufmg.dees.insane.model.disc.element.ParametricElement;
import br.ufmg.dees.insane.ui.rich.full.command.AnalyseModelCommand;
import br.ufmg.dees.insane.ui.rich.full.command.AttributesSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.CheckDataCommand;
import br.ufmg.dees.insane.ui.rich.full.command.CheckDataInteractiveCommand;
import br.ufmg.dees.insane.ui.rich.full.command.CloseCommand;
import br.ufmg.dees.insane.ui.rich.full.command.CubicCommand;
import br.ufmg.dees.insane.ui.rich.full.command.CurveCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DeleteCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DiagramsSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DiscretizeCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DoesNothingCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DxDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DyDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.DzDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmAnalysisModelCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmAttributesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmConcForcesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmCrossSectionCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmDistForcesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmElasticConnectionsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmGaussPointCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmIniEqNodalForcesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmLiberationsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmMaterialCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmPreStrainsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ElmTempChangesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ExitCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ExportJPEGCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ExportPDFCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ExportPSCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ExportXMLCommand;
import br.ufmg.dees.insane.ui.rich.full.command.FitCommand;
import br.ufmg.dees.insane.ui.rich.full.command.FrameCommand;
import br.ufmg.dees.insane.ui.rich.full.command.FxDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.FyDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.FzDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.GeneralSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.GridCommand;
import br.ufmg.dees.insane.ui.rich.full.command.GridSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ImportXMLCommand;
import br.ufmg.dees.insane.ui.rich.full.command.InquiryCommand;
import br.ufmg.dees.insane.ui.rich.full.command.LastZoomCommand;
import br.ufmg.dees.insane.ui.rich.full.command.LimitsSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.LineCommand;
import br.ufmg.dees.insane.ui.rich.full.command.MappingCommand;
import br.ufmg.dees.insane.ui.rich.full.command.MeshCommand;
import br.ufmg.dees.insane.ui.rich.full.command.MxDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.MyDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.MzDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NewFileCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodeAngleCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodeForcesCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodeParametersCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodePreDisplacementsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodeRestraintsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.NodeSpringCommand;
import br.ufmg.dees.insane.ui.rich.full.command.OpenCommand;
import br.ufmg.dees.insane.ui.rich.full.command.PartAllPrimitCommand;
import br.ufmg.dees.insane.ui.rich.full.command.PartPrimitCommand;
import br.ufmg.dees.insane.ui.rich.full.command.PointCommand;
import br.ufmg.dees.insane.ui.rich.full.command.PolylineCommand;
import br.ufmg.dees.insane.ui.rich.full.command.PrintCommand;
import br.ufmg.dees.insane.ui.rich.full.command.QuadCommand;
import br.ufmg.dees.insane.ui.rich.full.command.RedrawCommand;
import br.ufmg.dees.insane.ui.rich.full.command.RegionCommand;
import br.ufmg.dees.insane.ui.rich.full.command.RxDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.RyDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.RzDiagramCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SaveFileAsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SaveFileCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ScalesSettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SelectAllCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SelectCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SetViewGlobalAxisCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SetViewLocalAxisCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SetViewNodeLabelCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SettingsCommand;
import br.ufmg.dees.insane.ui.rich.full.command.SnapCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ViewReportCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ZoomAllCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ZoomCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ZoomInCommand;
import br.ufmg.dees.insane.ui.rich.full.command.ZoomOutCommand;
import br.ufmg.dees.insane.ui.rich.full.controller.DeformController;
import br.ufmg.dees.insane.ui.rich.full.controller.DiagramsController;
import br.ufmg.dees.insane.ui.rich.full.controller.ElementsController;
import br.ufmg.dees.insane.ui.rich.full.controller.GeometricController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridDiagramsController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridElementsController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridGeometricController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridMeshingController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridNodesController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridPostProcessorController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridProcessorController;
import br.ufmg.dees.insane.ui.rich.full.controller.GridReactionsController;
import br.ufmg.dees.insane.ui.rich.full.controller.MappingController;
import br.ufmg.dees.insane.ui.rich.full.controller.MeshingController;
import br.ufmg.dees.insane.ui.rich.full.controller.NodesController;
import br.ufmg.dees.insane.ui.rich.full.controller.PostProcessorController;
import br.ufmg.dees.insane.ui.rich.full.controller.ProcessorController;
import br.ufmg.dees.insane.ui.rich.full.controller.ReactionsController;
import br.ufmg.dees.insane.ui.rich.full.controller.RegionController;
import br.ufmg.dees.insane.ui.rich.full.dialogs.CrossSectionDialog;
import br.ufmg.dees.insane.ui.rich.full.dialogs.GlobalAnalysisModelDialog;
import br.ufmg.dees.insane.ui.rich.full.dialogs.MaterialDialog;
import br.ufmg.dees.insane.ui.rich.learn.learn_view.LearnInterface;

/**
 * A class representing the main window on the screen and the manager of the program.<br>
 * All users' processes come through this class.<br>
 * It's used to manage the whole program in order to have an efficient kind of consistence.
 *
 * @author Flavio Fonseca, Roque Pitangueira, Samuel Penna
 * @version 1.0
 * @since September 2006
 */
public class InsaneInternalInterface extends InternalInterface implements TreeSelectionListener {
    
    /**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;
	private static Model model;
    private InsaneView view = new InsaneView(this);
    private DrawingArea drawingArea = new DrawingArea(view);
    private InsaneProperties properties;
	
    //Main panels
    private JPanel drawArea = new JPanel();
	private DefaultMutableTreeNode top = new DefaultMutableTreeNode("Targets");
    private JTree tree = new JTree(top);
    private JScrollPane treeView = new JScrollPane(tree);
	private JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeView, drawArea);
    
    //Commands
    
    private Command newFileCmd = new NewFileCommand(this);
    private Command openCmd = new OpenCommand(this);
    private Command saveFileCmd = new SaveFileCommand(this);
    private Command saveFileAsCmd = new SaveFileAsCommand(this);
    private Command printCmd = new PrintCommand(this);
    private Command exportJPEGCmd = new ExportJPEGCommand(this);
    private Command exportPSCmd = new ExportPSCommand(this);
	private Command exportXMLCmd = new ExportXMLCommand(this);
	private Command exportPDFCmd = new ExportPDFCommand(this);
	private Command importCmd = new ImportXMLCommand(this);
    private Command closeCmd = new CloseCommand(this);
    
    private Command exitCmd = new ExitCommand(this);
    private Command settingsCmd = new SettingsCommand(this);
	private Command genSettingsCmd = new GeneralSettingsCommand(this);
	private Command limSettingsCmd = new LimitsSettingsCommand(this);
	private Command gridSettingsCmd = new GridSettingsCommand(this);
	private Command scaSettingsCmd = new ScalesSettingsCommand(this);
	private Command attSettingsCmd = new AttributesSettingsCommand(this);
	private Command diaSettingsCmd = new DiagramsSettingsCommand(this);
	private Command gridCmd = new GridCommand(this);
    private Command snapCmd = new SnapCommand(this);
    private Command lineCmd = new LineCommand(this);
	private Command polylineCmd = new PolylineCommand(this);
	private Command quadCmd = new QuadCommand(this);
	private Command cubicCmd = new CubicCommand(this);
    private Command pointCmd = new PointCommand(this);
	private Command mkGCurveCmd = new CurveCommand(this);
	private Command mkGRegionCmd = new RegionCommand(this);
	private Command mkGRegion2Cmd = mkGRegionCmd;
	private Command mkGRegion3Cmd = mkGRegionCmd;
	private Command mkGRegion4Cmd = mkGRegionCmd;
	private Command setFrameCmd = new FrameCommand(this);
    private Command selectAllCmd = new SelectAllCommand(this);
    private Command deleteCmd = new DeleteCommand(this);
    private Command zoomCmd = new ZoomCommand(this);
    private Command zoomInCmd = new ZoomInCommand(this);
    private Command zoomOutCmd = new ZoomOutCommand(this);
    private Command fitCmd = new FitCommand(this);
    private Command zoomAllCmd = new ZoomAllCommand(this);
    private Command lastZoomCmd = new LastZoomCommand(this);
    private Command redrawCmd = new RedrawCommand(this);
	private Command viewGlobalAxisCmd = new SetViewGlobalAxisCommand(this);
	private Command viewLocalAxisCmd = new SetViewLocalAxisCommand(this);
	private Command viewNodeLabelCmd = new SetViewNodeLabelCommand(this);
	private Command discretizeCmd = new DiscretizeCommand(this);
	private Command mappingCmd = new MappingCommand(this);
	private Command nodeAttributesCmd = new NodeParametersCommand(this);
	private Command nodeAngleCmd = new NodeAngleCommand(this);
	private Command nodeRestraintsCmd = new NodeRestraintsCommand(this);
	private Command nodeForcesCmd = new NodeForcesCommand(this);
	private Command nodePreDisplacementsCmd = new NodePreDisplacementsCommand(this);
	private Command nodeSpringCmd = new NodeSpringCommand(this);
	private Command elmAttributesCmd = new ElmAttributesCommand(this);
	private Command elmElasticConnectionsCmd = new ElmElasticConnectionsCommand(this);
	private Command elmAnalysisModelCmd = new ElmAnalysisModelCommand(this);
	private Command elmMaterialCmd = new ElmMaterialCommand(this);
	private Command elmCrossSectionCmd = new ElmCrossSectionCommand(this);
	private Command elmLiberationsCmd = new ElmLiberationsCommand(this);
	private Command elmConcForcesCmd = new ElmConcForcesCommand(this);
	private Command elmDistForcesCmd = new ElmDistForcesCommand(this);
	private Command elmTempChangesCmd = new ElmTempChangesCommand(this);
	private Command elmPreStrainsCmd = new ElmPreStrainsCommand(this);
	private Command elmIniEqNodalForcesCmd = new ElmIniEqNodalForcesCommand(this);
	private Command elmGaussPointCmd = new ElmGaussPointCommand(this);
	private UndoCommand undoCmd = new UndoCommand(this);
    private RedoCommand redoCmd = new RedoCommand(this);
	private Command partPrimitCmd = new PartPrimitCommand(this);
	private Command partAllPrimitCmd = new PartAllPrimitCommand(this);
	private Command meshCmd = new MeshCommand(this);
	private Command inquiryCmd = new InquiryCommand(this);
	private Command checkDataCmd = new CheckDataCommand(this);
	private Command analyseModelCmd = new AnalyseModelCommand(this);
	private Command viewReportCmd = new ViewReportCommand(this);
	private Command viewFxDiagramCmd = new FxDiagramCommand(this);
	private Command viewFyDiagramCmd = new FyDiagramCommand(this);
	private Command viewFzDiagramCmd = new FzDiagramCommand(this);
	private Command viewMxDiagramCmd = new MxDiagramCommand(this);
	private Command viewMyDiagramCmd = new MyDiagramCommand(this);
	private Command viewMzDiagramCmd = new MzDiagramCommand(this);
	private Command viewDxDiagramCmd = new DxDiagramCommand(this);
	private Command viewDyDiagramCmd = new DyDiagramCommand(this);
	private Command viewDzDiagramCmd = new DzDiagramCommand(this);
	private Command viewRxDiagramCmd = new RxDiagramCommand(this);
	private Command viewRyDiagramCmd = new RyDiagramCommand(this);
	private Command viewRzDiagramCmd = new RzDiagramCommand(this);
	
	//Handler for Console events
	private InsaneConsoleHandler consoleHandler = new InsaneConsoleHandler(this);
	
    //Menu
    
    private JMenuBar menuBar = new JMenuBar();
    
    private JMenu menuFile = new JMenu();
    private CmdMenu itemNew = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/New16.gif")));
    private CmdMenu itemOpen = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Open16.gif")));
    private CmdMenu itemSave = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Save16.gif")));
    private CmdMenu itemSaveAs = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/SaveAs16.gif")));
    private CmdMenu itemPrint = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Print16.gif")));
    private JMenu menuExport = new JMenu();
    private CmdMenu itemJPEG = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Export16.gif")));
    private CmdMenu itemPS = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Export16.gif")));
	private CmdMenu itemXML = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Export16.gif")));
	private CmdMenu itemPDF = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Export16.gif")));
	private JMenu menuImport = new JMenu();
	private CmdMenu itemImport = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Import16.gif")));
    private CmdMenu itemClose = new CmdMenu();
    private CmdMenu itemExit = new CmdMenu();
    
    private JMenu menuEdit = new JMenu();
    private CmdMenu itemUndo = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Undo16.gif")));
    private CmdMenu itemRedo = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Redo16.gif")));
    private CmdMenu itemCut = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Cut16.gif")));
    private CmdMenu itemCopy = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Copy16.gif")));
    private CmdMenu itemPaste = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Paste16.gif")));
    private CmdMenu itemSelectAll = new CmdMenu();
    private CmdMenu itemDelete = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Delete16.gif")));
    
    private JMenu menuView = new JMenu();
    private JMenu menuZoom = new JMenu();
    private CmdMenu itemWindow = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Zoom16.gif")));
    private CmdMenu itemZoomIn = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomIn16.gif")));
    private CmdMenu itemZoomOut = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomOut16.gif")));
    private CmdMenu itemExtents = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomExtents16.gif")));
    private CmdMenu itemAll = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomAll16.gif")));
    private CmdMenu itemLastZoom = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomPrevious16.gif")));
	private CmdMenu itemRedraw = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Redraw16.gif")));
	private CmdCheckBoxMenu itemViewGlobalAxis = new CmdCheckBoxMenu();
	private CmdCheckBoxMenu itemViewLocalAxis = new CmdCheckBoxMenu();
	private CmdCheckBoxMenu itemViewNodeLabel = new CmdCheckBoxMenu();
	
    private JMenu menuSettings = new JMenu();
    private CmdMenu itemSettings = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Settings16.gif")));
    private CmdMenu itemGenSettings = new CmdMenu();
	private CmdMenu itemLimSettings = new CmdMenu();
	private CmdMenu itemGridSettings = new CmdMenu();
	private CmdMenu itemScaSettings = new CmdMenu();
	private CmdMenu itemAttSettings = new CmdMenu();
	private CmdMenu itemDiaSettings = new CmdMenu();
    
    private JMenu menuDraw = new JMenu();
    private CmdMenu itemPoint = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Point16.gif")));
    private CmdMenu itemLine = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Line16.gif")));
	private CmdMenu itemPolyline = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Polyline16.gif")));
	private CmdMenu itemQuad = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Quad16.gif")));
	private CmdMenu itemCubic = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Cubic16.gif")));
	
	private JMenu menuRegion = new JMenu();
	private CmdMenu itemMakeCurve = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PartPrimit16.gif")));
	private JMenu menuMakeRegion = new JMenu();
	private CmdMenu itemMakeLofting = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Lofting16.gif")));
	private CmdMenu itemMakeTrilinear = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Trilinear16.gif")));
	private CmdMenu itemMakeBilinear = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Bilinear16.gif")));
	private CmdMenu itemSetFrame = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Line16.gif")));
	
	private JMenu menuPartition = new JMenu();
    private CmdMenu itemPartition = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PartPrimit16.gif")));
    private CmdMenu itemPartitionAll = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PartAllPrimit16.gif")));
    
	private JMenu menuGeneration = new JMenu();
	private CmdMenu itemMesh = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Mesh16.gif")));
	private CmdMenu itemInquiry = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Inquiry16.gif")));
	
	private JMenu menuAttributes = new JMenu();
    private JMenu menuNode = new JMenu();
	private JMenu menuElm = new JMenu();
    private CmdMenu itemNAngle = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/NodeAngle16.gif")));
	private CmdMenu itemNRestraints = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Restraint16.gif")));
	private CmdMenu itemNForces = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/NodalLoad16.gif")));
	private CmdMenu itemNPreDisplacements = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Displace16.gif")));
	private CmdMenu itemNSpring = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Spring16.gif")));
	private CmdMenu itemEAnalysis = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/AnalysisModel16.gif")));
	private CmdMenu itemEMaterial = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Material16.gif")));
	private CmdMenu itemECrossSection = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/CrossSection16.gif")));
	private CmdMenu itemELiberations = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Liberation16.gif")));
	private CmdMenu itemECForces = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ConcLoad16.gif")));
	private CmdMenu itemEDForces= new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/DistLoad16.gif")));
	private CmdMenu itemETempChanges = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/TempChange16.gif")));
	private CmdMenu itemEPreStrains = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PreStrains16.gif")));
	private CmdMenu itemEIniEqNForce = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/IniEqForce16.gif")));
	private CmdMenu itemEElasticConnections = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ElasticConnections16.gif")));
	private CmdMenu itemElmGaussPoint = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Point16.gif")));
	
    private JMenu menuProcessor = new JMenu();
    
    //Interactive Processor Menu
    private JMenu menuProcInteractive = new JMenu();
      
	private JMenu menuProcAutomatic = new JMenu();
	private CmdMenu itemAutoCheckData = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/CheckData16.gif")));
    private CmdMenu itemAutoAnalyseModel = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Solve16.gif")));
	
	private JMenu menuReport = new JMenu();
    private CmdMenu itemReport = new CmdMenu(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Report16.gif")));
	
    //Tools
    
    private JPanel toolPanel = new JPanel();
    
    private JToolBar fileToolBar = new JToolBar();
    private CmdButton newB = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/New16.gif")));
    private CmdButton open = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Open16.gif")));
    private CmdButton save = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Save16.gif")));
    private CmdButton saveAs = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/SaveAs16.gif")));
    private CmdButton print = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Print16.gif")));
    
    private JToolBar zoomToolBar = new JToolBar();
    private CmdButton redraw = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Redraw16.gif")));
    private CmdButton fit = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomExtents16.gif")));
    private CmdButton zoom = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Zoom16.gif")));
    private CmdButton zoomIn = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomIn16.gif")));
    private CmdButton zoomOut = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomOut16.gif")));
    private CmdButton zoomAll = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomAll16.gif")));
	private CmdButton zoomPrevious = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ZoomPrevious16.gif")));
    
    private JToolBar editToolBar = new JToolBar();
    private CmdButton undo = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Undo16.gif")));
    private CmdButton redo = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Redo16.gif")));
    private CmdButton cut = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Cut16.gif")));
    private CmdButton copy = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Copy16.gif")));
    private CmdButton paste = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Paste16.gif")));
    private CmdButton delete = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Delete16.gif")));
    
    private JToolBar drawToolBar = new JToolBar();
    private CmdButton point = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Point16.gif")));
    private CmdButton line = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Line16.gif")));
	private CmdButton polyline = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Polyline16.gif")));
	private CmdButton quad = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Quad16.gif")));
	private CmdButton cubic = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Cubic16.gif")));
	
    private JToolBar subregionsToolBar = new JToolBar();
	private CmdButton mkGCurve = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/AddCurve16.gif")));
	private CmdButton mkGRegion2 = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Lofting16.gif")));
	private CmdButton mkGRegion3 = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Trilinear16.gif")));
	private CmdButton mkGRegion4 = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Bilinear16.gif")));
	private CmdButton setFrame = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Line16.gif")));
	
	private JToolBar partToolBar = new JToolBar();
    private CmdButton partPrimit = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PartPrimit16.gif")));
    private CmdButton partAllPrimit = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PartAllPrimit16.gif")));
	
	private JToolBar meshToolBar = new JToolBar();
    private CmdButton mesh = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Mesh16.gif")));
    private CmdButton inquiry = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Inquiry16.gif")));
	
	private JToolBar nodeToolBar = new JToolBar();
    private CmdButton nodeAttributes = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/NodeParameters16.gif")));
	private CmdButton nodeAngle = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/NodeAngle16.gif")));
	private CmdButton nodeRestraints = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Restraint16.gif")));
	private CmdButton nodeForces = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/NodalLoad16.gif")));
	private CmdButton nodePreDisplacements = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Displace16.gif")));
	private CmdButton nodeSpring = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Spring16.gif")));
	
	private JToolBar elmToolBar = new JToolBar();
    private CmdButton elmAttributes = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ElmAttributes16.gif")));
	private CmdButton elmAnalysisModel = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/AnalysisModel16.gif")));
	private CmdButton elmMaterial = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Material16.gif")));
	private CmdButton elmCrossSection = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/CrossSection16.gif")));
	private CmdButton elmLiberations = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Liberation16.gif")));
	private CmdButton elmCForces = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ConcLoad16.gif")));
	private CmdButton elmDForces = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/DistLoad16.gif")));
	private CmdButton elmTempChanges = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/TempChange16.gif")));
	private CmdButton elmPreStrains = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/PreStrains16.gif")));
	private CmdButton elmIniEqNForce = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/IniEqForce16.gif")));
	private CmdButton elmElasticConnections = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/ElasticConnections16.gif")));
	private CmdButton elmGaussPoint = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Point16.gif")));
	
	private JToolBar autoProcToolBar = new JToolBar();
    private CmdButton autoCheckData = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/CheckData16.gif")));
    private CmdButton autoAnalyseModel = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Solve16.gif")));
    
        
	private JToolBar reportToolBar = new JToolBar();
    private CmdButton ViewReport = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Report16.gif")));
	
	private JToolBar effDiagramsToolBar = new JToolBar();
    private CmdButton FxDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Fx.gif")));
	private CmdButton FyDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Fy.gif")));
	private CmdButton FzDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Fz.gif")));
	private CmdButton MxDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Mx.gif")));
	private CmdButton MyDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/My.gif")));
	private CmdButton MzDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Mz.gif")));
	
	private JToolBar disDiagramsToolBar = new JToolBar();
	private CmdButton DxDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Dx.gif")));
	private CmdButton DyDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Dy.gif")));
	private CmdButton DzDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Dz.gif")));
	private CmdButton RxDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Rx.gif")));
	private CmdButton RyDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Ry.gif")));
	private CmdButton RzDiagram = new CmdButton(new ImageIcon(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Rz.gif")));
	
	//In-Out Panel
	private JPanel inOutBar = new JPanel(new BorderLayout(6,0));
    private Console console;
		
    private JPanel statusBar = new JPanel();
    
    private JTextField messageField = new JTextField(21);
    private JTextField coordField = new JTextField(1);
    private JPanel state = new JPanel();
    
    private CmdToggleButton grid = new CmdToggleButton();
    private CmdToggleButton snap = new CmdToggleButton();
    
//*****************************************************************************
	
    /**
     * The constructor method. <br>
     * Calls the init() method throwing an exception.
     */
    public InsaneInternalInterface(ResourceBundle bundle) {
		super(bundle);
        try {
            init();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
	
//*****************************************************************************
	
    /**
     * It's called by the constructor. <br>
     * Sets Panels, components and provides a window listener.
     */
    private void init() throws Exception {
        
    	top.setUserObject(bundle.getString("treeTargets"));
    	
    	properties = new InsaneProperties(bundle);
    	
    	this.setTitle("INSANE " + this.getProperties().getVersion());
    	this.setFonts();
    	this.setSize(new Dimension(800,640));
        this.setMaximizable(true);
		this.setClosable(true);
		
		console = new Console(this);
		
		coordField = new JTextField(bundle.getString("gCoords") + " :",1);
		grid = new CmdToggleButton(bundle.getString("gGrid"));
		snap = new CmdToggleButton(bundle.getString("gSnap"));
		
		this.messageField.setText("Escola de Engenharia da UFMG");
		
		this.getContentPane().setLayout(new BorderLayout());
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        
//        Image ico = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Insane64.gif"));
//        this.setDesktopIcon(ico);
        
		toolPanel.setLayout(new BoxLayout(toolPanel, BoxLayout.X_AXIS));
        this.getContentPane().add(toolPanel, BorderLayout.NORTH);
        
        splitPane.setOneTouchExpandable(true);
        splitPane.setDividerLocation(0);
        splitPane.setBorder(BorderFactory.createEmptyBorder(2,3,1,3));
		
        drawArea.setLayout(new BorderLayout());
        drawArea.setBorder(BorderFactory.createEmptyBorder(0,0,0,3));
		
        createNodes(top);
        tree.putClientProperty("JTree.lineStyle", "Angled");
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
		tree.setExpandsSelectedPaths(true);
        tree.addTreeSelectionListener(this);
        
        this.getContentPane().add(splitPane, BorderLayout.CENTER);
        
        //Setting Menus
        
        //Setting menu file
        
        menuFile.add(itemNew);
        itemNew.setCommand(newFileCmd);
        itemNew.addActionListener(this);
        itemNew.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        
        menuFile.add(itemOpen);
        itemOpen.setCommand(openCmd);
        itemOpen.addActionListener(this);
        itemOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        
        menuFile.add(itemSave);
        itemSave.setCommand(saveFileCmd);
        itemSave.setEnabled(false);
        itemSave.addActionListener(this);
        itemSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        
        menuFile.add(itemSaveAs);
        itemSaveAs.setCommand(saveFileAsCmd);
        itemSaveAs.setEnabled(false);
        itemSaveAs.addActionListener(this);
		itemSaveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.SHIFT_MASK));
        
        menuFile.add(itemClose);
        itemClose.setCommand(closeCmd);
        itemClose.setEnabled(false);
        itemClose.addActionListener(this);
        itemClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));
        
        menuFile.addSeparator();
        
        menuFile.add(itemPrint);
        itemPrint.setCommand(printCmd);
        itemPrint.setEnabled(false);
        itemPrint.addActionListener(this);
        itemPrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
        
		menuFile.add(menuImport);
		
		menuImport.add(itemImport);
        itemImport.setCommand(importCmd);
        itemImport.setEnabled(true);
		itemImport.addActionListener(this);
        
		menuFile.add(menuExport);
        menuExport.setEnabled(false);
		
		menuExport.add(itemJPEG);
		itemJPEG.setCommand(exportJPEGCmd);
		itemJPEG.addActionListener(this);
        
        menuExport.add(itemPDF);
        itemPDF.setCommand(exportPDFCmd);
		itemPDF.addActionListener(this);
		
		menuExport.add(itemPS);
        itemPS.setCommand(exportPSCmd);
		itemPS.addActionListener(this);
        
		menuExport.add(itemXML);
        itemXML.setCommand(exportXMLCmd);
		itemXML.addActionListener(this);
		
		menuFile.addSeparator();
        
        menuFile.add(itemExit);
        itemPrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
		itemExit.setCommand(exitCmd);
        itemExit.addActionListener(this);
        
        //Setting menu edit
        
        menuEdit.add(itemUndo);
        itemUndo.setEnabled(false);
        itemUndo.setCommand(undoCmd);
        itemUndo.addActionListener(this);
        itemUndo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
        
        menuEdit.add(itemRedo);
        itemRedo.setEnabled(false);
        itemRedo.setCommand(redoCmd);
        itemRedo.addActionListener(this);
        itemRedo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK));
        
        menuEdit.addSeparator();
        
        menuEdit.add(itemCut);
        itemCut.setEnabled(false);
        itemCut.addActionListener(this);
        itemCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
        
        menuEdit.add(itemCopy);
        itemCopy.setEnabled(false);
        itemDelete.addActionListener(this);
        itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
        
        menuEdit.add(itemPaste);
        itemPaste.setEnabled(false);
        itemPaste.addActionListener(this);
        itemPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
        
        menuEdit.addSeparator();
        
        menuEdit.add(itemSelectAll);
        itemSelectAll.setCommand(selectAllCmd);
        itemSelectAll.addActionListener(this);
        itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
        
        menuEdit.add(itemDelete);
        itemDelete.setCommand(deleteCmd);
        itemDelete.addActionListener(this);
        itemDelete.setAccelerator(KeyStroke.getKeyStroke("DELETE"));
        
        //Setting menu view
        
        menuZoom.add(itemWindow);
        itemWindow.setCommand(zoomCmd);
        itemWindow.addActionListener(this);
        itemWindow.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.SHIFT_MASK));
        
        menuZoom.add(itemZoomIn);
        itemZoomIn.setCommand(zoomInCmd);
        itemZoomIn.addActionListener(this);
        itemZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ActionEvent.SHIFT_MASK));
		
        menuZoom.add(itemZoomOut);
        itemZoomOut.setCommand(zoomOutCmd);
        itemZoomOut.addActionListener(this);
        itemZoomOut.setAccelerator(KeyStroke.getKeyStroke("MINUS"));
        
        menuZoom.add(itemAll);
        itemAll.setCommand(zoomAllCmd);
        itemAll.addActionListener(this);
        itemAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.SHIFT_MASK));
		
		menuZoom.add(itemExtents);
        itemExtents.setCommand(fitCmd);
        itemExtents.addActionListener(this);
        itemExtents.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.SHIFT_MASK));
        
        menuZoom.add(itemLastZoom);
        itemLastZoom.setCommand(lastZoomCmd);
        itemLastZoom.addActionListener(this);
        itemLastZoom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.SHIFT_MASK));
		
		menuView.add(menuZoom);
        
		menuView.addSeparator();
		
		menuView.add(itemRedraw);
        itemRedraw.setCommand(redrawCmd);
		itemLastZoom.addActionListener(this);
		
		menuView.addSeparator();
		
		menuView.add(itemViewGlobalAxis);
        itemViewGlobalAxis.setCommand(viewGlobalAxisCmd);
		itemViewGlobalAxis.addActionListener(this);
		itemViewGlobalAxis.setSelected(true);
		
		menuView.add(itemViewLocalAxis);
        itemViewLocalAxis.setCommand(viewLocalAxisCmd);
		itemViewLocalAxis.addActionListener(this);
		itemViewLocalAxis.setSelected(false);
		
        menuView.add(itemViewNodeLabel);
        itemViewNodeLabel.setCommand(viewNodeLabelCmd);
		itemViewNodeLabel.addActionListener(this);
		itemViewNodeLabel.setSelected(true);
		
		//Setting menu draw
		menuDraw.add(itemPoint);
        itemPoint.setCommand(pointCmd);
        itemPoint.setEnabled(false);
		itemPoint.addActionListener(this);
        
        menuDraw.add(itemLine);
        itemLine.setCommand(lineCmd);
        itemLine.setEnabled(false);
		itemLine.addActionListener(this);
		
        menuDraw.add(itemPolyline);
        itemPolyline.setCommand(polylineCmd);
        itemPolyline.setEnabled(false);
		itemPolyline.addActionListener(this);
		
		menuDraw.add(itemQuad);
        itemQuad.setCommand(quadCmd);
        itemQuad.setEnabled(false);
		itemQuad.addActionListener(this);
		
		menuDraw.add(itemCubic);
        itemCubic.setCommand(cubicCmd);
        itemCubic.setEnabled(false);
		itemCubic.addActionListener(this);
		
		//Setting menu region
		
		menuRegion.add(itemMakeCurve);
        itemMakeCurve.setCommand(mkGCurveCmd);
        itemMakeCurve.setEnabled(false);
        itemMakeCurve.addActionListener(this);
		
        menuRegion.add(menuMakeRegion);
		
        menuMakeRegion.add(itemMakeLofting);
        itemMakeLofting.setCommand(mkGRegion2Cmd);
        itemMakeLofting.setEnabled(false);
        itemMakeLofting.addActionListener(this);
		
        menuMakeRegion.add(itemMakeTrilinear);
        itemMakeTrilinear.setCommand(mkGRegion3Cmd);
        itemMakeTrilinear.setEnabled(false);
        itemMakeTrilinear.addActionListener(this);
		
        menuMakeRegion.add(itemMakeBilinear);
        itemMakeBilinear.setCommand(mkGRegion4Cmd);
        itemMakeBilinear.setEnabled(false);
        itemMakeBilinear.addActionListener(this);
		
		menuMakeRegion.add(itemSetFrame);
        itemSetFrame.setCommand(setFrameCmd);
        itemSetFrame.setEnabled(true);
        itemSetFrame.addActionListener(this);
		
		//Setting menu partition
		
        menuPartition.add(itemPartition);
        itemPartition.setCommand(partPrimitCmd);
        itemPartition.setEnabled(false);
		itemPartition.addActionListener(this);
		
        menuPartition.add(itemPartitionAll);
        itemPartitionAll.setCommand(partAllPrimitCmd);
        itemPartitionAll.setEnabled(false);
		itemPartitionAll.addActionListener(this);
		
		//Setting menu generation
		menuGeneration.setMnemonic(KeyEvent.VK_M);
		
        menuGeneration.add(itemMesh);
        itemMesh.setCommand(meshCmd);
        itemMesh.setEnabled(false);
        itemMesh.addActionListener(this);
		
        menuGeneration.add(itemInquiry);
        itemInquiry.setCommand(inquiryCmd);
        itemInquiry.setEnabled(false);
        itemInquiry.addActionListener(this);
		
        //Setting submenu nodal attributes
        menuNode.add(itemNAngle);
        itemNAngle.setCommand(nodeAngleCmd);
        itemNAngle.addActionListener(this);
        
        menuNode.add(itemNRestraints);
        itemNRestraints.setCommand(nodeRestraintsCmd);
        itemNRestraints.addActionListener(this);
        
        menuNode.add(itemNForces);
        itemNForces.setCommand(nodeForcesCmd);
        itemNForces.addActionListener(this);
        
        menuNode.add(itemNPreDisplacements);
        itemNPreDisplacements.setCommand(nodePreDisplacementsCmd);
        itemNPreDisplacements.addActionListener(this);
        
		menuNode.add(itemNSpring);
        itemNSpring.setCommand(nodeSpringCmd);
        itemNSpring.addActionListener(this);
        
		//Setting submenu element attributes
		
		menuElm.add(itemEAnalysis);
        itemEAnalysis.setCommand(elmAnalysisModelCmd);
        itemEAnalysis.addActionListener(this);
        
		menuElm.add(itemEMaterial);
        itemEMaterial.setCommand(elmMaterialCmd);
        itemEMaterial.addActionListener(this);
        
		menuElm.add(itemECrossSection);
        itemECrossSection.setCommand(elmCrossSectionCmd);
        itemECrossSection.addActionListener(this);
        
		menuElm.add(itemECForces);
        itemECForces.setCommand(elmConcForcesCmd);
        itemECForces.addActionListener(this);
        
		menuElm.add(itemEDForces);
        itemEDForces.setCommand(elmDistForcesCmd);
        itemEDForces.addActionListener(this);
        
		menuElm.add(itemETempChanges);
        itemETempChanges.setCommand(elmTempChangesCmd);
        itemETempChanges.addActionListener(this);
        
		menuElm.add(itemELiberations);
        itemELiberations.setCommand(elmLiberationsCmd);
        itemELiberations.addActionListener(this);
        
		menuElm.add(itemEPreStrains);
        itemEPreStrains.setCommand(elmPreStrainsCmd);
        itemEPreStrains.addActionListener(this);
        
		menuElm.add(itemEIniEqNForce);
        itemEIniEqNForce.setCommand(elmIniEqNodalForcesCmd);
        itemEIniEqNForce.addActionListener(this);
        
        menuElm.add(itemElmGaussPoint);
        itemElmGaussPoint.setCommand(elmGaussPointCmd);
        itemElmGaussPoint.addActionListener(this);
        
		menuElm.add(itemEElasticConnections);
        itemEElasticConnections.setCommand(elmElasticConnectionsCmd);
        itemEElasticConnections.addActionListener(this);
        itemEElasticConnections.setEnabled(false); //Remove when correctly implemented
		
		menuAttributes.add(menuNode);
        menuAttributes.add(menuElm);
        
		//Setting menu settings
        menuSettings.add(itemSettings);
		itemSettings.setCommand(settingsCmd);
		itemSettings.addActionListener(this);
		
		menuSettings.addSeparator();
		
		menuSettings.add(itemGenSettings);
		itemGenSettings.setCommand(genSettingsCmd);
		itemGenSettings.addActionListener(this);
		
		menuSettings.add(itemLimSettings);
		itemLimSettings.setCommand(limSettingsCmd);
		itemLimSettings.addActionListener(this);
		
		menuSettings.add(itemGridSettings);
		itemGridSettings.setCommand(gridSettingsCmd);
		itemGridSettings.addActionListener(this);
		
		menuSettings.add(itemScaSettings);
		itemScaSettings.setCommand(scaSettingsCmd);
		itemScaSettings.addActionListener(this);
		
		menuSettings.add(itemAttSettings);
		itemAttSettings.setCommand(attSettingsCmd);
		itemAttSettings.addActionListener(this);
		
		menuSettings.add(itemDiaSettings);
		itemDiaSettings.setCommand(diaSettingsCmd);
		itemDiaSettings.addActionListener(this);
		
		//Setting menu processor
		menuProcessor.add(menuProcInteractive);
		menuProcessor.add(menuProcAutomatic);
		
       //Setting menu processor automatic
        menuProcAutomatic.add(itemAutoCheckData);
        itemAutoCheckData.setCommand(checkDataCmd);
        itemAutoCheckData.setEnabled(false);
		itemAutoCheckData.addActionListener(this);
		
        menuProcAutomatic.add(itemAutoAnalyseModel);
        itemAutoAnalyseModel.setCommand(analyseModelCmd);
        itemAutoAnalyseModel.setEnabled(false);
		itemAutoAnalyseModel.addActionListener(this);
        
        //Setting menu report
        menuReport.add(itemReport);
        itemReport.setCommand(viewReportCmd);
        itemReport.addActionListener(this);
		
        this.setJMenuBar(menuBar);
        
        //Setting tools
        
        //Setting file tool bar
        
        fileToolBar.add(newB);
        newB.setCommand(newFileCmd);
        newB.addActionListener(this);
        
        fileToolBar.add(open);
        open.setCommand(openCmd);
        open.addActionListener(this);
        
        fileToolBar.add(save);
        save.setCommand(saveFileCmd);
        save.addActionListener(this);
        
        fileToolBar.add(saveAs);
        saveAs.setCommand(saveFileAsCmd);
        saveAs.addActionListener(this);
        
        fileToolBar.add(print);
        print.setCommand(printCmd);
        print.addActionListener(this);
        
        //Setting zoom tool bar
        
        zoomToolBar.add(zoom);
        zoom.setCommand(zoomCmd);
        zoom.addActionListener(this);
        
        zoomToolBar.add(zoomIn);
        zoomIn.setCommand(zoomInCmd);
        zoomIn.addActionListener(this);
        
        zoomToolBar.add(zoomOut);
        zoomOut.setCommand(zoomOutCmd);
        zoomOut.addActionListener(this);
        
        zoomToolBar.add(zoomAll);
        zoomAll.setCommand(zoomAllCmd);
        zoomAll.addActionListener(this);
        
        zoomToolBar.add(fit);
        fit.setCommand(fitCmd);
        fit.addActionListener(this);
        
		zoomToolBar.add(zoomPrevious);
        zoomPrevious.setCommand(lastZoomCmd);
        zoomPrevious.addActionListener(this);
		
        zoomToolBar.add(redraw);
        redraw.setCommand(redrawCmd);
        redraw.addActionListener(this);
        
        //Setting edit tool bar
        
        editToolBar.add(undo);
        undo.setEnabled(false);
        undo.setCommand(undoCmd);
        undo.addActionListener(this);
        
        editToolBar.add(redo);
        redo.setEnabled(false);
        redo.setCommand(redoCmd);
        redo.addActionListener(this);
        
        editToolBar.add(cut);
        cut.setEnabled(false);
        cut.addActionListener(this);
        
        editToolBar.add(copy);
        copy.setEnabled(false);
        copy.addActionListener(this);
        
        editToolBar.add(paste);
        paste.setEnabled(false);
        paste.addActionListener(this);
        
        editToolBar.add(delete);
        delete.setCommand(deleteCmd);
        delete.addActionListener(this);
        
        //Setting draw tool bar
        
        drawToolBar.add(point);
        point.setCommand(pointCmd);
        point.addActionListener(this);
        
		drawToolBar.add(line);
		line.setCommand(lineCmd);
		line.addActionListener(this);
		
        drawToolBar.add(polyline);
        polyline.setCommand(polylineCmd);
        polyline.addActionListener(this);
		
		drawToolBar.add(quad);
        quad.setCommand(quadCmd);
        quad.addActionListener(this);
		
		drawToolBar.add(cubic);
        cubic.setCommand(cubicCmd);
        cubic.addActionListener(this);
		
		//Setting subregions tool bar
        
		subregionsToolBar.add(mkGCurve);
		mkGCurve.addActionListener(this);
		mkGCurve.setCommand(mkGCurveCmd);
		
		subregionsToolBar.add(mkGRegion2);
		mkGRegion2.addActionListener(this);
		mkGRegion2.setCommand(mkGRegion2Cmd);
		
		subregionsToolBar.add(mkGRegion3);
		mkGRegion3.addActionListener(this);
		mkGRegion3.setCommand(mkGRegion3Cmd);
		
		subregionsToolBar.add(mkGRegion4);
		mkGRegion4.addActionListener(this);
		mkGRegion4.setCommand(mkGRegion4Cmd);
		
		subregionsToolBar.add(setFrame);
		setFrame.addActionListener(this);
		setFrame.setCommand(setFrameCmd);
		
		//Setting part tool bar
        
		partToolBar.add(partPrimit);
		partPrimit.addActionListener(this);
		partPrimit.setCommand(partPrimitCmd);
		
		partToolBar.add(partAllPrimit);
		partAllPrimit.addActionListener(this);
		partAllPrimit.setCommand(partAllPrimitCmd);
		
		//Setting mesh tool bar
        
		meshToolBar.add(mesh);
		mesh.addActionListener(this);
		mesh.setCommand(meshCmd);
		
		meshToolBar.add(inquiry);
		inquiry.addActionListener(this);
		inquiry.setCommand(inquiryCmd);
		
		//Setting node tool bar
        
		nodeToolBar.add(nodeAttributes);
		nodeAttributes.addActionListener(this);
		nodeAttributes.setCommand(nodeAttributesCmd);
		
		nodeToolBar.add(nodeAngle);
		nodeAngle.addActionListener(this);
		nodeAngle.setCommand(nodeAngleCmd);
		
		nodeToolBar.add(nodeRestraints);
		nodeRestraints.addActionListener(this);
		nodeRestraints.setCommand(nodeRestraintsCmd);
		
		nodeToolBar.add(nodeForces);
		nodeForces.addActionListener(this);
		nodeForces.setCommand(nodeForcesCmd);
		
		nodeToolBar.add(nodePreDisplacements);
		nodePreDisplacements.addActionListener(this);
		nodePreDisplacements.setCommand(nodePreDisplacementsCmd);
		
		nodeToolBar.add(nodeSpring);
		nodeSpring.addActionListener(this);
		nodeSpring.setCommand(nodeSpringCmd);
		
		//Setting element tool bar
		
		elmToolBar.add(elmAttributes);
		elmAttributes.addActionListener(this);
		elmAttributes.setCommand(elmAttributesCmd);
		
		elmToolBar.add(elmAnalysisModel);
		elmAnalysisModel.addActionListener(this);
		elmAnalysisModel.setCommand(elmAnalysisModelCmd);
		
		elmToolBar.add(elmMaterial);
		elmMaterial.addActionListener(this);
		elmMaterial.setCommand(elmMaterialCmd);
		
		elmToolBar.add(elmCrossSection);
		elmCrossSection.addActionListener(this);
		elmCrossSection.setCommand(elmCrossSectionCmd);
		
		elmToolBar.add(elmCForces);
		elmCForces.addActionListener(this);
		elmCForces.setCommand(elmConcForcesCmd);
		
		elmToolBar.add(elmDForces);
		elmDForces.addActionListener(this);
		elmDForces.setCommand(elmDistForcesCmd);
		
		elmToolBar.add(elmTempChanges);
		elmTempChanges.addActionListener(this);
		elmTempChanges.setCommand(elmTempChangesCmd);
		
		elmToolBar.add(elmLiberations);
		elmLiberations.addActionListener(this);
		elmLiberations.setCommand(elmLiberationsCmd);
		
		elmToolBar.add(elmPreStrains);
		elmPreStrains.addActionListener(this);
		elmPreStrains.setCommand(elmPreStrainsCmd);
		
		elmToolBar.add(elmIniEqNForce);
		elmIniEqNForce.addActionListener(this);
		elmIniEqNForce.setCommand(elmIniEqNodalForcesCmd);
		
		elmToolBar.add(elmElasticConnections);
		elmElasticConnections.addActionListener(this);
		elmElasticConnections.setCommand(elmElasticConnectionsCmd);
		elmElasticConnections.setEnabled(false); //Remove when correctly implemented
		
		elmToolBar.add(elmGaussPoint);
		elmGaussPoint.addActionListener(this);
		elmGaussPoint.setCommand(elmGaussPointCmd);
		
		
		//Setting automatic processor tool bar
        		
		autoProcToolBar.add(autoCheckData);
		autoCheckData.addActionListener(this);
		autoCheckData.setCommand(checkDataCmd);
		
		autoProcToolBar.add(autoAnalyseModel);
		autoAnalyseModel.addActionListener(this);
		autoAnalyseModel.setCommand(analyseModelCmd);
					
		//Setting report tool bar
        reportToolBar.add(ViewReport);
        ViewReport.addActionListener(this);
        ViewReport.setCommand(viewReportCmd);
		
		//Setting diagrams tool bar
        effDiagramsToolBar.add(FxDiagram);
		FxDiagram.addActionListener(this);
		FxDiagram.setCommand(viewFxDiagramCmd);
		
		effDiagramsToolBar.add(FyDiagram);
		FyDiagram.addActionListener(this);
		FyDiagram.setCommand(viewFyDiagramCmd);
		
		effDiagramsToolBar.add(FzDiagram);
		FzDiagram.addActionListener(this);
		FzDiagram.setCommand(viewFzDiagramCmd);
		
		effDiagramsToolBar.add(MxDiagram);
		MxDiagram.addActionListener(this);
		MxDiagram.setCommand(viewMxDiagramCmd);
		
		effDiagramsToolBar.add(MyDiagram);
		MyDiagram.addActionListener(this);
		MyDiagram.setCommand(viewMyDiagramCmd);
		
		effDiagramsToolBar.add(MzDiagram);
		MzDiagram.addActionListener(this);
		MzDiagram.setCommand(viewMzDiagramCmd);
		
		disDiagramsToolBar.add(DxDiagram);
		DxDiagram.addActionListener(this);
		DxDiagram.setCommand(viewDxDiagramCmd);
		
		disDiagramsToolBar.add(DyDiagram);
		DyDiagram.addActionListener(this);
		DyDiagram.setCommand(viewDyDiagramCmd);
		
		disDiagramsToolBar.add(DzDiagram);
		DzDiagram.addActionListener(this);
		DzDiagram.setCommand(viewDzDiagramCmd);
		
		disDiagramsToolBar.add(RxDiagram);
		RxDiagram.addActionListener(this);
		RxDiagram.setCommand(viewRxDiagramCmd);
		
		disDiagramsToolBar.add(RyDiagram);
		RyDiagram.addActionListener(this);
		RyDiagram.setCommand(viewRyDiagramCmd);
		
		disDiagramsToolBar.add(RzDiagram);
		RzDiagram.addActionListener(this);
		RzDiagram.setCommand(viewRzDiagramCmd);
		
		//Setting status bar
        
        statusBar.setLayout(new BoxLayout(statusBar, BoxLayout.X_AXIS));
		
        messageField.setEditable(false);
		messageField.setBorder(BorderFactory.createEmptyBorder(2,3,1,3));
        coordField.setEditable(false);
		coordField.setBorder(BorderFactory.createEmptyBorder(2,3,1,3));
        state.setLayout(new GridLayout(1,3,1,1));
        
		grid.setMargin(new Insets(0,1,0,1));
        grid.setCommand(gridCmd);
        grid.addActionListener(this);
        state.add(grid);
        
        snap.setMargin(new Insets(0,1,0,1));
        snap.setCommand(snapCmd);
        snap.addActionListener(this);
        state.add(snap);
        
        statusBar.add(coordField);
        statusBar.add(state);
		statusBar.add(messageField);
        
		console.addListener(consoleHandler);
		
		inOutBar.add(BorderLayout.SOUTH, statusBar);
		inOutBar.add(BorderLayout.NORTH, console);
		
        this.getContentPane().add(inOutBar,BorderLayout.SOUTH);
        
		this.setCoord("" + 0.0, "" + 0.0);

		this.setAllLabels();
		
        setInitialInterface();
        
    }
    
//*****************************************************************************
	
	/** Creates the nodes of the tree.
	* @param top The root of the tree.
	*/
    private void createNodes(DefaultMutableTreeNode top) {
        DefaultMutableTreeNode folder = null;
        DefaultMutableTreeNode subFolder = null;
        DefaultMutableTreeNode child = null;
        
		folder = new DefaultMutableTreeNode(bundle.getString("treePreProcessor"));
		top.add(folder);
		
		subFolder = new DefaultMutableTreeNode(bundle.getString("treeGeometry"));
		folder.add(subFolder);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeShapes"));
		subFolder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeSubregions"));
		subFolder.add(child);
        
		subFolder = new DefaultMutableTreeNode(bundle.getString("treeMeshing"));
		folder.add(subFolder);
		
		child = new DefaultMutableTreeNode(bundle.getString("treePartition"));
		subFolder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeGeneration"));
		subFolder.add(child);
		
		subFolder = new DefaultMutableTreeNode(bundle.getString("treeAttributes"));
		folder.add(subFolder);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeGlobalAnalysisModel"));
		subFolder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeMaterial"));
		subFolder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeCrossSection"));
		subFolder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeNodalAttributes"));
		subFolder.add(child);
        
		child = new DefaultMutableTreeNode(bundle.getString("treeElementAttributes"));
		subFolder.add(child);
		
		folder = new DefaultMutableTreeNode(bundle.getString("treeProcessor"));
		top.add(folder);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeInteractive"));
		folder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeAutomatic"));
		folder.add(child);
		
		folder = new DefaultMutableTreeNode(bundle.getString("treePostProcessor"));
		top.add(folder);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeReactions"));
		folder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeDiagrams"));
		folder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeDeform"));
		folder.add(child);
		
		child = new DefaultMutableTreeNode(bundle.getString("treeReport"));
		folder.add(child);
		
    }
	
//*****************************************************************************
	
    /**
     * Returns the current model.
     * @return The current model.
     */
    public Model getModel() {
        return model;
    }
    
//*****************************************************************************
	
	/** Sets the Model.
	*@param mdl The Model to be set.
	*/
    public void setModel(Model mdl) {
        model = mdl;
		drawingArea.setZoom(model.getState().getLimits());
		drawingArea.setPrecision(model.getState().getPrecision());
        drawingArea.setSnap(model.getState().getSnap());
        drawingArea.setGridColor(model.getState().gridColor);
        drawingArea.setGrid(model.getState().isGridOn());
		drawingArea.setGridIncs(model.getState().getXInc(),
        model.getState().getYInc());
        drawingArea.setBackground(model.getState().getBackground());
	}
    
//*****************************************************************************
	
	/** Return the SplitPane.
	*@return The SplitPane.
	*/
    public JSplitPane getSplitPane() {
        return splitPane;
    }
	
//*****************************************************************************
	
	/** Return the current ModelState.
	*@return The current ModelState.
	*/
    public ModelState getModelState() {
        return model.getState();
    }
    
//*****************************************************************************
	
	/** Returns the DrawingArea.
	*@return The DrawingArea.
	*/
    public DrawingArea getDrawing() {
        return drawingArea;
    }
	
//*****************************************************************************
	
	/** Returns the properties.
	*@return The properties.
	*/
    public InsaneProperties getProperties() {
        return properties;
    }
    
//*****************************************************************************
	
	/** Returns the current controller.
	*@return The current controller.
	*/
    public Controller getController() {
        return view.getController();
    }
    
//*****************************************************************************
	
	/** Sets the initial Interface. */
    public void setInitialInterface() {
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(false);
		itemSaveAs.setEnabled(false);
		itemClose.setEnabled(false);
		itemPrint.setEnabled(false);
		menuExport.setEnabled(false);
		
		grid.setEnabled(false);
		snap.setEnabled(false);
		
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(false);
		saveAs.setEnabled(false);
		print.setEnabled(false);
		
		tree.expandRow(0);
		tree.expandRow(1);
		tree.expandRow(2);
		tree.expandRow(5);
		tree.expandRow(8);
		tree.expandRow(14);
		tree.expandRow(17);
		tree.setEnabled(false);
		
		splitPane.setDividerLocation(0);
		
		drawArea.removeAll();
		setMessage("Escola de Engenharia da UFMG");
		drawArea.add(new ImageDA(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Insane.jpg")), BorderLayout.CENTER);
		drawArea.repaint();
		drawArea.updateUI();
		
		console.setVisible(false);
		
		this.setCoord("" + 0.0, "" + 0.0);
		
		this.repaint();
    }
    
//*****************************************************************************
	
	/** Sets the Interface to Shapes mode. */
    public void setToShapes() {
        menuBar.removeAll();
        menuBar.add(menuFile);
        itemSave.setEnabled(true);
        itemSaveAs.setEnabled(true);
        itemClose.setEnabled(true);
        itemPrint.setEnabled(true);
        menuExport.setEnabled(true);
		menuImport.setEnabled(true);
        menuBar.add(menuEdit);
        menuBar.add(menuView);
        menuBar.add(menuDraw);
        itemPoint.setEnabled(true);
        itemLine.setEnabled(true);
        itemPolyline.setEnabled(true);
		itemQuad.setEnabled(true);
		itemCubic.setEnabled(true);
        menuBar.add(menuSettings);
		
        toolPanel.removeAll();
        toolPanel.add(fileToolBar);
        save.setEnabled(true);
        saveAs.setEnabled(true);
        print.setEnabled(true);
		delete.setEnabled(true);
        toolPanel.add(editToolBar);
        toolPanel.add(zoomToolBar);
        toolPanel.add(drawToolBar);
        
		console.setVisible(true);
		
        grid.setEnabled(true);
        snap.setEnabled(true);
        
		drawingArea.setSnap(true);
		model.getState().setSnap(true);
		drawingArea.setSnap(true);
		drawingArea.setRepainting(true);
		drawingArea.repaint();
        
        consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
        tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeShapes"), 0, Position.Bias.Forward));
        
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new GeometricController(model, drawingArea));
		} else {
			view.setController(new GridGeometricController(model, drawingArea));
		}
		view.getController().compose();
        
        drawArea.removeAll();
        drawArea.add(drawingArea, BorderLayout.CENTER);
        drawingArea.removeAllCommands();
        drawingArea.setClickedCommand(new SelectCommand(this));
        drawingArea.setCursor();
        drawArea.repaint();
        drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.SHAPES)
			addOutputText(bundle.getString("gmSetGeometry"));
		setMessage(bundle.getString("gmCreatePrimitives"));
		model.getState().setActualTreeNode(ModelState.SHAPES);
        this.getJMenuBar().updateUI();
        this.repaint();
    }
	
//*****************************************************************************
	
	public void setToSubregions() {
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuRegion);
		itemMakeCurve.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(subregionsToolBar);
		mkGRegion2.setEnabled(false);
		mkGRegion3.setEnabled(false);
		mkGRegion4.setEnabled(false);
		setFrame.setEnabled(true);
        
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setSnap(false);
		model.getState().setSnap(false);
		drawingArea.setRepainting(false);
		drawingArea.setSnap(false);
		drawingArea.repaint();
        
		grid.setSelected(model.getState().isGridOn());
		snap.setSelected(model.getState().getSnap());
        
		tree.setEnabled(true);
		tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeSubregions"), 0, Position.Bias.Forward));
        
		view.setController(new RegionController(this, model, drawingArea));
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new SelectCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.SUBREGIONS)
			addOutputText(bundle.getString("gmSubregions"));
		setMessage(bundle.getString("gmCreateCurves"));
		model.getState().setActualTreeNode(ModelState.SUBREGIONS);
        this.getJMenuBar().updateUI();
        this.repaint();
		
	}
	
//*****************************************************************************
	
	/** Sets the Interface to Partition mode. */
    public void setToPartition() {
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuPartition);
		itemPartition.setEnabled(true);
		itemPartitionAll.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(true);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(partToolBar);
		partPrimit.setEnabled(true);
		partAllPrimit.setEnabled(true);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
		tree.setSelectionPath(tree.getNextMatch(bundle.getString("treePartition"), 0, Position.Bias.Forward));
        
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new MeshingController(model, drawingArea));
		} else {
			view.setController(new GridMeshingController(model, drawingArea));
		}
		view.getController().compose();
        
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new SelectCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		mappingCmd.execute();
		
		if (model.getState().getActualTreeNode() != ModelState.PARTITION)
			addOutputText(bundle.getString("gmSelectPrimitives"));
		setMessage(bundle.getString("gmPartitionPrimitives"));
		model.getState().setActualTreeNode(ModelState.PARTITION);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	public void setToGeneration() {
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuGeneration);
		itemMesh.setEnabled(true);
		itemInquiry.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(meshToolBar);
		mesh.setEnabled(true);
		inquiry.setEnabled(true);
        
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		grid.setSelected(model.getState().isGridOn());
		snap.setSelected(model.getState().getSnap());
		
		tree.setEnabled(true);
		tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeGeneration"), 0, Position.Bias.Forward));
		
		view.setController(new MappingController(model, drawingArea));
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new SelectCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.GENERATION)
			addOutputText(bundle.getString("gmGeneration"));
		setMessage(bundle.getString("gmGeneration"));
		model.getState().setActualTreeNode(ModelState.GENERATION);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to ElmAttributes mode. */
    public void setToElmAttributes() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.SUBREGIONS) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		if (model.getState().getActualTreeNode() == ModelState.GENERATION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuAttributes);
		menuNode.setEnabled(false);
		menuElm.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(elmToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setSnap(false);
		model.getState().setSnap(false);
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		this.setStateButtons();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeElementAttributes"), 0, Position.Bias.Forward));
		
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		ListIterator elms = model.getDiscreteModel().getElementsList().listIterator();
		while(elms.hasNext()){
		    Element elm = (Element)elms.next();
		    elm.setAnalysisModel(model.getDiscreteModel().getGlobalAnalysisModel());
		}
		
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new ElementsController(model, drawingArea));
			((ElementsController)view.getController()).setParent(this);
		} else {
			view.setController(new GridElementsController(model, drawingArea));
			((GridElementsController)view.getController()).setParent(this);
		}
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new SelectCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.ELM_ATTRIBUTES)
			addOutputText(bundle.getString("gmSetElmAttributes"));
		setMessage(bundle.getString("gmSetElmAttributes"));
		model.getState().setActualTreeNode(ModelState.ELM_ATTRIBUTES);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to ProcAutomatic mode. */
    public void setToProcAutomatic() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuProcessor);
		menuProcInteractive.setEnabled(false);
		menuProcAutomatic.setEnabled(true);
		itemAutoCheckData.setEnabled(true);
		itemAutoAnalyseModel.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(autoProcToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeAutomatic"), 0, Position.Bias.Forward));
		
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new ProcessorController(model, drawingArea));
			((ProcessorController)view.getController()).setParent(this);
		} else {
			view.setController(new GridProcessorController(model, drawingArea));
			((GridProcessorController)view.getController()).setParent(this);
		}
		view.getController().compose();
		//splitPane.setDividerLocation(275);
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new DoesNothingCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.PROC_AUTOMATIC)
			addOutputText(bundle.getString("gmAutomaticProcessor"));
		this.setMessage(bundle.getString("gmAutomaticProcessor"));
		model.getState().setActualTreeNode(ModelState.PROC_AUTOMATIC);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
    
    
	/** Sets the Interface to ProcInteractive mode. */
    public void setToProcInteractive() {
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		CheckDataInteractiveCommand check = new CheckDataInteractiveCommand(this);
		check.execute();
		
		if (check.getDataOK()==true){
			LearnInterface frame = new LearnInterface(model.getDiscreteModel());
			frame.setModel(model.getDiscreteModel());
	        frame.validate();
			//Centers the window
	        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	        Dimension frameSize = frame.getSize();
	        if (frameSize.height > screenSize.height)
	            frameSize.height = screenSize.height;
	        if (frameSize.width > screenSize.width)
	            frameSize.width = screenSize.width;
	        frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
	      	frame.setVisible(true);
	      	}
    }
    
//  *****************************************************************************
    
	/** Sets the Interface to Reactions mode. */
    public void setToReactions() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeReactions"), 0, Position.Bias.Forward));
		
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new ReactionsController(model, drawingArea));
			((ReactionsController)view.getController()).setParent(this);
		} else {
			view.setController(new GridReactionsController(model, drawingArea));
			((GridReactionsController)view.getController()).setParent(this);
		}
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new DoesNothingCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.REACTIONS)
			addOutputText(bundle.getString("gmReactions"));
		this.setMessage(bundle.getString("gmReactions"));
		model.getState().setActualTreeNode(ModelState.REACTIONS);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to Diagrams mode. */
    public void setToDiagrams() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuReport.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(effDiagramsToolBar);
		toolPanel.add(disDiagramsToolBar);
        
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (gAnlType.equals("PlaneFrame")) {
			FxDiagram.setEnabled(true);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(false);
			MxDiagram.setEnabled(false);
			MyDiagram.setEnabled(false);
			MzDiagram.setEnabled(true);
			DxDiagram.setEnabled(true);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(false);
			RxDiagram.setEnabled(false);
			RyDiagram.setEnabled(false);
			RzDiagram.setEnabled(true);
		} else if (gAnlType.equals("PlaneTruss")) {
			FxDiagram.setEnabled(true);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(false);
			MxDiagram.setEnabled(false);
			MyDiagram.setEnabled(false);
			MzDiagram.setEnabled(true);
			DxDiagram.setEnabled(true);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(false);
			RxDiagram.setEnabled(false);
			RyDiagram.setEnabled(false);
			RzDiagram.setEnabled(true);
		} else if (gAnlType.equals("Beam")) {
			FxDiagram.setEnabled(false);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(false);
			MxDiagram.setEnabled(false);
			MyDiagram.setEnabled(false);
			MzDiagram.setEnabled(true);
			DxDiagram.setEnabled(false);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(false);
			RxDiagram.setEnabled(false);
			RyDiagram.setEnabled(false);
			RzDiagram.setEnabled(true);
		} else if (gAnlType.equals("Grid")) {
			FxDiagram.setEnabled(false);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(false);
			MxDiagram.setEnabled(true);
			MyDiagram.setEnabled(false);
			MzDiagram.setEnabled(true);
			DxDiagram.setEnabled(false);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(false);
			RxDiagram.setEnabled(true);
			RyDiagram.setEnabled(false);
			RzDiagram.setEnabled(true);
		} else if (gAnlType.equals("SpaceTruss")) {
			FxDiagram.setEnabled(true);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(true);
			MxDiagram.setEnabled(false);
			MyDiagram.setEnabled(false);
			MzDiagram.setEnabled(false);
			DxDiagram.setEnabled(true);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(true);
			RxDiagram.setEnabled(false);
			RyDiagram.setEnabled(false);
			RzDiagram.setEnabled(false);
		} else if (gAnlType.equals("SpaceFrame")) {
			FxDiagram.setEnabled(true);
			FyDiagram.setEnabled(true);
			FzDiagram.setEnabled(true);
			MxDiagram.setEnabled(true);
			MyDiagram.setEnabled(true);
			MzDiagram.setEnabled(true);
			DxDiagram.setEnabled(true);
			DyDiagram.setEnabled(true);
			DzDiagram.setEnabled(true);
			RxDiagram.setEnabled(true);
			RyDiagram.setEnabled(true);
			RzDiagram.setEnabled(true);
		}
		
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeDiagrams"), 0, Position.Bias.Forward));
		
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new DiagramsController(model, drawingArea));
			((DiagramsController)view.getController()).setParent(this);
		} else {
			view.setController(new GridDiagramsController(model, drawingArea));
			((GridDiagramsController)view.getController()).setParent(this);
		}
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new DoesNothingCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.DIAGRAMS)
			addOutputText(bundle.getString("gmDiagrams"));
		this.setMessage(bundle.getString("gmDiagrams"));
		model.getState().setActualTreeNode(ModelState.DIAGRAMS);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to Deform mode. */
    public void setToDeform() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuReport.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeDeform"), 0, Position.Bias.Forward));
		
		//if (!(gAnlType.equals("Grid"))) {
	    	view.setController(new DeformController(model, drawingArea));
			((DeformController)view.getController()).setParent(this);
		//} else {
		//	view.setController(new GridDeformController(model, drawingArea));
		//	((GridDeformController)view.getController()).setParent(this);
		//}
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new DoesNothingCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.DEFORM)
			addOutputText(bundle.getString("gmDeform"));
		this.setMessage(bundle.getString("gmDeform"));
		model.getState().setActualTreeNode(ModelState.DEFORM);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to Report mode. */
    public void setToReport() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuReport);
		menuReport.setEnabled(true);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(reportToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeReport"), 0, Position.Bias.Forward));
		
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new PostProcessorController(model, drawingArea));
			((PostProcessorController)view.getController()).setParent(this);
		} else {
			view.setController(new GridPostProcessorController(model, drawingArea));
			((GridPostProcessorController)view.getController()).setParent(this);
		}
		view.getController().compose();
		//splitPane.setDividerLocation(275);
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new DoesNothingCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.REPORT)
			addOutputText(bundle.getString("gmReport"));
		this.setMessage(bundle.getString("gmReport"));
		model.getState().setActualTreeNode(ModelState.REPORT);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Sets the Interface to GlobalAnalysisModel mode. */
    public void setToGlobalAnalysisModel() {
		
		GlobalAnalysisModelDialog dlg = new GlobalAnalysisModelDialog(this);
        dlg.showDialog();
		
		int node = model.getState().getActualTreeNode();
		if (node == ModelState.SHAPES || node == ModelState.PARTITION)
			setToTreeNode(ModelState.NODAL_ATTRIBUTES);
		else {
			if (node == ModelState.REACTIONS || node == ModelState.DIAGRAMS || node == ModelState.DEFORM)
				setToTreeNode(ModelState.PROC_AUTOMATIC);
			else
				setToTreeNode(model.getState().getActualTreeNode());
		}
    }
	
//*****************************************************************************
	
	/** Sets the Interface to MaterialsList mode. */
    public void setToMaterialsList() {
		
		MaterialDialog dlg = new MaterialDialog(this);
        dlg.showDialog();
		
		int node = model.getState().getActualTreeNode();
		if (node == ModelState.SHAPES || node == ModelState.PARTITION)
			setToTreeNode(ModelState.NODAL_ATTRIBUTES);
		else {
			if (node == ModelState.REACTIONS || node == ModelState.DIAGRAMS)
				setToTreeNode(ModelState.ELM_ATTRIBUTES);
			else
				setToTreeNode(model.getState().getActualTreeNode());
		}
    }
	
//*****************************************************************************
	
	/** Sets the Interface to CrossSectionsList mode. */
    public void setToCrossSectionsList() {
		
		CrossSectionDialog dlg = new CrossSectionDialog(this);
        dlg.showDialog();
		
		int node = model.getState().getActualTreeNode();
		if (node == ModelState.SHAPES || node == ModelState.PARTITION)
			setToTreeNode(ModelState.NODAL_ATTRIBUTES);
		else {
			if (node == ModelState.REACTIONS || node == ModelState.DIAGRAMS)
				setToTreeNode(ModelState.ELM_ATTRIBUTES);
			else
				setToTreeNode(model.getState().getActualTreeNode());
		}
    }
	
//*****************************************************************************
	
	/** Sets the Interface to NodalAttributes mode. */
    public void setToNodalAttributes() {
		
		if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.SUBREGIONS) {
			mappingCmd.execute();
			discretizeCmd.execute();
		}
		if (model.getState().getActualTreeNode() == ModelState.PARTITION)
			discretizeCmd.execute();
		if (model.getState().getActualTreeNode() == ModelState.GENERATION)
			discretizeCmd.execute();
		
		menuBar.removeAll();
		menuBar.add(menuFile);
		itemSave.setEnabled(true);
		itemSaveAs.setEnabled(true);
		itemClose.setEnabled(true);
		itemPrint.setEnabled(true);
		menuExport.setEnabled(true);
		menuImport.setEnabled(true);
		menuBar.add(menuEdit);
		menuBar.add(menuView);
		menuBar.add(menuAttributes);
		menuNode.setEnabled(true);
		menuElm.setEnabled(false);
		menuBar.add(menuSettings);
        
		toolPanel.removeAll();
		toolPanel.add(fileToolBar);
		save.setEnabled(true);
		saveAs.setEnabled(true);
		print.setEnabled(true);
		delete.setEnabled(false);
		toolPanel.add(editToolBar);
		toolPanel.add(zoomToolBar);
		toolPanel.add(nodeToolBar);
        
		console.setVisible(true);
		
		grid.setEnabled(true);
		snap.setEnabled(true);
		
		drawingArea.setRepainting(false);
		drawingArea.repaint();
        
		consoleHandler.setToCommandMode();
		consoleHandler.setKeybCommand(null);
		
		this.setStateButtons();
		this.setAxisCheckBoxes();
		
		tree.setEnabled(true);
	    tree.setSelectionPath(tree.getNextMatch(bundle.getString("treeNodalAttributes"), 0, Position.Bias.Forward));
		
		String gAnlType = model.getDiscreteModel().getGlobalAnalysisModel().getType();
		if (!(gAnlType.equals("Grid"))) {
			view.setController(new NodesController(model, drawingArea));
			((NodesController)view.getController()).setParent(this);
		} else {
			view.setController(new GridNodesController(model, drawingArea));
			((GridNodesController)view.getController()).setParent(this);
		}
		view.getController().compose();
		
		drawArea.removeAll();
		drawArea.add(drawingArea, BorderLayout.CENTER);
		drawingArea.removeAllCommands();
		drawingArea.setClickedCommand(new SelectCommand(this));
		drawingArea.setCursor();
		drawArea.repaint();
		drawArea.updateUI();
		
		if (model.getState().getActualTreeNode() != ModelState.NODAL_ATTRIBUTES)
			addOutputText(bundle.getString("gmSetNodAttributes"));
		setMessage(bundle.getString("gmSetNodAttributes"));
		model.getState().setActualTreeNode(ModelState.NODAL_ATTRIBUTES);
		this.getJMenuBar().updateUI();
		this.repaint();
    }
	
//*****************************************************************************
	
	/** Adds a Command to the undoList.*/
    public void addToUndo(Command cmd) {
        undoCmd.add(cmd);
        itemUndo.setEnabled(true);
        undo.setEnabled(true);
    }
    
//*****************************************************************************
	
	/** Adds a Command to the redoList.*/
    public void addToRedo(Command cmd) {
        if (!(cmd instanceof DeleteCommand)){
            redoCmd.add(cmd);
            itemRedo.setEnabled(true);
            redo.setEnabled(true);
        }
    }
	
//*****************************************************************************
	
	/** Disables the redo command.*/
    public void nothingToRedo() {
        redoCmd.clear();
        itemRedo.setEnabled(false);
        redo.setEnabled(false);
    }
	
//*****************************************************************************
	
	/** Disables the undo command.*/
    public void nothingToUndo() {
        undoCmd.clear();
        itemUndo.setEnabled(false);
        undo.setEnabled(false);
	}
	
//*****************************************************************************
	
    /**
     * Sets the Status Bar coord text.
     * @param x The first "X" coordinate.
     * @param y The second "Y" coordinate.
     */
    public void setCoord(String x, String y) {
        this.coordField.setText(bundle.getString("gCoords") + ": " + x + ", " + y);
    }
    
//*****************************************************************************
	
    /**
     * Sets the Status Bar message.
     * @param str The text to be shown
     */
    public void setMessage(String str) {
        this.messageField.setText(str);
	}
	
//*****************************************************************************
	
    /**
     * Appends a message to the output panel.
     * @param str The message to be appended.
     */
    public void addOutputText(String str) {
        this.console.addOutputText(str);
	}
    
//*****************************************************************************
	
    /**
     * Closes the current model and returns true if successfull.
     * @return   A boolean if the current model was closed or not.
     */
    public boolean closeModel() {
        
		boolean ret = true;
        if (model != null) {
            int value = 10;
            value = JOptionPane.showConfirmDialog(this,
                    bundle.getString("gmWouldSave") + " " + model.getState().getName()+ " ?", bundle.getString("gmWarning"),
                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (value == JOptionPane.YES_OPTION){
                saveFileCmd.execute();
            }else if(value == JOptionPane.CANCEL_OPTION){
                ret = false;
            }
        }
        if (ret) {
            model = null;
            this.setMessage(" ");
            this.setCoord(" ", " ");
            this.setInitialInterface();
        }
        return ret;
    }
    
//*****************************************************************************
	
	/** Method which executes the desired action to each command.*/
    public void actionPerformed(ActionEvent evt) {
        CommandHolder obj = (CommandHolder)evt.getSource();
		obj.getCommand().execute();
    }
    
//*****************************************************************************
	
	/** Method which executes the desired action to selected node of the tree.*/
    public void valueChanged(TreeSelectionEvent e) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
        
        if (node == null) return;
        
		boolean processed = false;
		boolean isHypostatic = model.getDiscreteModel().isHypostatic();
		
		//delete this variable after implementing 2D post-processor
		boolean onlyFrameElements = true;
		ListIterator elms = model.getDiscreteModel().getElementsList().listIterator();
		while (elms.hasNext()) {
			Element elm = (Element)elms.next();
			if (elm instanceof ParametricElement)
				onlyFrameElements = false;
		}
		
		int numEq = model.getDiscreteModel().getNumberOfEquations();
		int numRes = model.getDiscreteModel().getNumberOfRestraints();
		if(numEq == 0 && numRes == 0)
			processed = false;
		else processed = true;
		
        Object nodeObj = node.getUserObject();
        if (node.isLeaf()) {
            
        	if (nodeObj.equals(bundle.getString("treeGeometry"))) {
                if (model.getState().getActualTreeNode() > ModelState.GENERATION) {
                	int retVal = JOptionPane.showConfirmDialog(null,
    						bundle.getString("gmBack2Geometry"), bundle.getString("gmWarning"), JOptionPane.YES_NO_OPTION);
					if (retVal == JOptionPane.YES_OPTION)
						setToShapes();
					else setToTreeNode(model.getState().getActualTreeNode());
				} else setToShapes();
				
			} else if (nodeObj.equals(bundle.getString("treeSubregions"))) {
                if (model.getState().getActualTreeNode() > ModelState.GENERATION) {
					int retVal = JOptionPane.showConfirmDialog(null,
							bundle.getString("gmBack2Subregions"), bundle.getString("gmWarning"), JOptionPane.YES_NO_OPTION);
					if (retVal == JOptionPane.YES_OPTION)
						setToSubregions();
					else setToTreeNode(model.getState().getActualTreeNode());
				} else setToSubregions();
            
			}else if (nodeObj.equals(bundle.getString("treePartition"))) {
              	if (model.getState().getActualTreeNode() > ModelState.GENERATION) {
              		int retVal = JOptionPane.showConfirmDialog(null,
    						bundle.getString("gmBack2Meshing"), bundle.getString("gmWarning"), JOptionPane.YES_NO_OPTION);
					if (retVal == JOptionPane.YES_OPTION)
						setToPartition();
					else setToTreeNode(model.getState().getActualTreeNode());
				} else setToPartition();
			
			}else if (nodeObj.equals(bundle.getString("treeGeneration"))) {
              	if (model.getState().getActualTreeNode() > ModelState.GENERATION) {
					int retVal = JOptionPane.showConfirmDialog(null,
							bundle.getString("gmBack2Meshing"), bundle.getString("gmWarning"), JOptionPane.YES_NO_OPTION);
					if (retVal == JOptionPane.YES_OPTION)
						setToGeneration();
					else setToTreeNode(model.getState().getActualTreeNode());
				} else setToGeneration();
				
			}else if (nodeObj.equals(bundle.getString("treeGlobalAnalysisModel"))) {
				setToGlobalAnalysisModel();
			}else if (nodeObj.equals(bundle.getString("treeMaterial"))) {
				setToMaterialsList();
			}else if (nodeObj.equals(bundle.getString("treeCrossSection"))) {
				setToCrossSectionsList();
			}else if (nodeObj.equals(bundle.getString("treeNodalAttributes"))) {
				setToNodalAttributes();
			}else if (nodeObj.equals(bundle.getString("treeElementAttributes"))) {
				setToElmAttributes();
				
			}else if (nodeObj.equals(bundle.getString("treeInteractive"))) {
				setToProcInteractive();
			}else if (nodeObj.equals(bundle.getString("treeAutomatic"))) {
				setToProcAutomatic();
			
			}else if (nodeObj.equals(bundle.getString("treeReactions"))) {
				if (onlyFrameElements) {
					if (processed) {
						if (!isHypostatic) {
							setToReactions();
						} else {
							JOptionPane.showMessageDialog(null,
									bundle.getString("gmHypModelCantShowReactions"),
									bundle.getString("gmCantShowReactions"), JOptionPane.WARNING_MESSAGE);
							setToReport();
						}
					} else {
						JOptionPane.showMessageDialog(null,
								bundle.getString("gmMustAnalyse"),
								bundle.getString("gmModelNotAnalysed"), JOptionPane.WARNING_MESSAGE);
						setToProcAutomatic();
					}
				} else {
					JOptionPane.showMessageDialog(null,
							bundle.getString("gmNo2DPostP"),
							bundle.getString("gmNo2DPostP2"), JOptionPane.ERROR_MESSAGE);
					setToProcAutomatic();
				}
			
			}else if (nodeObj.equals(bundle.getString("treeDiagrams"))) {
				if (onlyFrameElements) {
					if (processed) {
						if (!isHypostatic) {
							setToDiagrams();
						} else {
							JOptionPane.showMessageDialog(null,
									bundle.getString("gmHypModelCantShowDiagrams"),
									bundle.getString("gmCantShowDiagrams"), JOptionPane.WARNING_MESSAGE);
							setToReport();
						}
					} else{
						JOptionPane.showMessageDialog(null,
								bundle.getString("gmMustAnalyse"),
								bundle.getString("gmModelNotAnalysed"), JOptionPane.WARNING_MESSAGE);
						setToProcAutomatic();
					}
				} else {
					JOptionPane.showMessageDialog(null,
					bundle.getString("gmNo2DPostP"),
					bundle.getString("gmNo2DPostP2"), JOptionPane.ERROR_MESSAGE);
					setToProcAutomatic();
				}
			}else if (nodeObj.equals(bundle.getString("treeDeform"))) {
				if (onlyFrameElements) {
					if (processed) {
						if (model.getDiscreteModel().getGlobalAnalysisModel().getType().equals("PlaneFrame")) {
							if (!isHypostatic) {
								setToDeform();
							} else {
								JOptionPane.showMessageDialog(null,
										bundle.getString("gmHypModelCantShowDeform"),
										bundle.getString("gmCantShowDeform"), JOptionPane.WARNING_MESSAGE);
										setToReport();
							}
						}else {
							JOptionPane.showMessageDialog(null,
							bundle.getString("gmJustDeform"),
							bundle.getString("gmSorry"), JOptionPane.WARNING_MESSAGE);
							setToProcAutomatic();
						}
					
					} else{
						JOptionPane.showMessageDialog(null,
								bundle.getString("gmMustAnalyse"),
								bundle.getString("gmModelNotAnalysed"), JOptionPane.WARNING_MESSAGE);
						setToProcAutomatic();
					}
				} else {
					JOptionPane.showMessageDialog(null,
							bundle.getString("gmNo2DPostP"),
							bundle.getString("gmNo2DPostP2"), JOptionPane.ERROR_MESSAGE);
					setToProcAutomatic();
				}
				
			}else if (nodeObj.equals(bundle.getString("treeReport"))) {
				if (onlyFrameElements) {
					setToReport();
				} else {
					JOptionPane.showMessageDialog(null,
							bundle.getString("gmNo2DPostP"),
							bundle.getString("gmNo2DPostP2"), JOptionPane.ERROR_MESSAGE);
					setToProcAutomatic();
				}
			}
		}
    }
    
//*****************************************************************************
	
	/** Sets the StateButtons of this Interface. */
	public void setStateButtons() {
		grid.setSelected(model.getState().isGridOn());
		snap.setSelected(model.getState().getSnap());
	};
	
//*****************************************************************************
	
	/** Sets the AxisCheckBoxes of this Interface. */
	public void setAxisCheckBoxes() {
		itemViewGlobalAxis.setSelected(model.getState().getViewGlobalAxis());
		itemViewLocalAxis.setSelected(model.getState().getViewLocalAxis());
	};
	
//*****************************************************************************
	
	/** Returns the Console of this Interface.
	*@return The Console of this Interface.
	*/
	public Console getConsole() {
		return console;
	};
	
//*****************************************************************************
	
	/** Returns the ConsoleHandler of this Interface.
	*@return The ConsoleHandler of this Interface.
	*/
	public ConsoleHandler getConsoleHandler() {
		return consoleHandler;
	}
	
//*****************************************************************************
	
	/** Returns the UndoCommand of this Interface.
	*@return The UndoCommand of this Interface.
	*/
	public UndoCommand getUndoCommand() {
		return undoCmd;
	}
	
//*****************************************************************************
	
	/** Returns the RedoCommand of this Interface.
	*@return The RedoCommand of this Interface.
	*/
	public RedoCommand getRedoCommand() {
		return redoCmd;
	}
	
//*****************************************************************************
	
	/** Sets the Interface to the specified tree node.
	*@param a A flag representing the desired tree node (see model.ModelState).
	*@see model.ModelState
	*/
	public void setToTreeNode(int a) {
		if (a == ModelState.SHAPES)
			this.setToShapes();
		else if (a == ModelState.PARTITION)
			this.setToPartition();
		else if (a == ModelState.NODAL_ATTRIBUTES)
			this.setToNodalAttributes();
		else if (a == ModelState.ELM_ATTRIBUTES)
			this.setToElmAttributes();
		else if (a == ModelState.PROC_INTERACTIVE)
			this.setToProcInteractive();
		else if (a == ModelState.PROC_AUTOMATIC)
			this.setToProcAutomatic();
		else if (a == ModelState.REACTIONS)
			this.setToReactions();
		else if (a == ModelState.DIAGRAMS)
			this.setToDiagrams();
		else if (a == ModelState.DEFORM)
			this.setToDeform();
		else if (a == ModelState.REPORT)
			this.setToReport();
	}
	
//*****************************************************************************
	
	/** Cleans the results stored at Model.
	*/
	public void cleanResults() {
		model.getDiscreteModel().cleanResults();
	}
	
//*****************************************************************************
	
	public void activeButton(int nc) {
		int siz = (int)nc;
		if (siz < 2){
			mkGRegion2.setEnabled(false);
			mkGRegion3.setEnabled(false);
			mkGRegion4.setEnabled(false);
			itemMakeLofting.setEnabled(false);
			itemMakeTrilinear.setEnabled(false);
			itemMakeBilinear.setEnabled(false);
		}
		if (siz == 2){
			mkGRegion2.setEnabled(true);
			itemMakeLofting.setEnabled(true);
		}
		if (siz == 3){
			mkGRegion2.setEnabled(false);
			itemMakeLofting.setEnabled(false);
			mkGRegion3.setEnabled(true);
			itemMakeTrilinear.setEnabled(true);
		}
		if (siz == 4){
			mkGRegion3.setEnabled(false);
			itemMakeTrilinear.setEnabled(false);
			mkGRegion4.setEnabled(true);
			itemMakeBilinear.setEnabled(true);
		}
		if (siz == 5){
			mkGRegion4.setEnabled(false);
			itemMakeBilinear.setEnabled(false);
		}
	}
	
//*****************************************************************************
	/**Returns this interface's ResourceBundle
	*@return This interface's ResourceBundle
	*/
	public ResourceBundle getResourceBundle(){
		return bundle;
	}
	
//*****************************************************************************
		
	/**Sets this interface's Locale
	*@param loc The Locale to be set
	*/
/*	public void setLocale(Locale loc){
		currentLocale = loc;
		bundle = ResourceBundle.getBundle("br.ufmg.dees.insane.langPack.InsaneLangPack", currentLocale);
		properties = new InsaneProperties(bundle);
	}
*/	
//*****************************************************************************
	
	/**Gets this interface's Locale
	*@return The current Locale
	*/
/*	public Locale getLocale(){
		return currentLocale;
	}
*/	
//*****************************************************************************
	
	/** Updates all labels to current locale ones.
	*/
	public void setAllLabels(){
		
		//General GUI elements
		top.setUserObject(bundle.getString("treeTargets"));
		coordField.setText(bundle.getString("gCoords") + " :");
		grid.setText(bundle.getString("gGrid"));
		snap.setText(bundle.getString("gSnap"));
		console.setAllLabels();
		
		//Menu itens
		menuFile.setText(bundle.getString("mFile"));
		menuFile.setMnemonic(Integer.parseInt(bundle.getString("mneFile")));
		itemNew.setText(bundle.getString("mNew"));
		itemNew.setMnemonic(Integer.parseInt(bundle.getString("mneNew")));
		itemOpen.setText(bundle.getString("mOpen"));
		itemOpen.setMnemonic(Integer.parseInt(bundle.getString("mneOpen")));
		itemSave.setText(bundle.getString("mSave"));
		itemSave.setMnemonic(Integer.parseInt(bundle.getString("mneSave")));
		itemSaveAs.setText(bundle.getString("mSaveAs"));
		itemSaveAs.setMnemonic(Integer.parseInt(bundle.getString("mneSaveAs")));
		itemClose.setText(bundle.getString("mClose"));
		itemClose.setMnemonic(Integer.parseInt(bundle.getString("mneClose")));
		itemPrint.setText(bundle.getString("mPrint"));
		itemPrint.setMnemonic(Integer.parseInt(bundle.getString("mnePrint")));
		menuImport.setText(bundle.getString("mImport"));
		menuImport.setMnemonic(Integer.parseInt(bundle.getString("mneImport")));
		itemImport.setText(bundle.getString("mImportXML"));
		itemImport.setMnemonic(Integer.parseInt(bundle.getString("mneImportXML")));
		menuExport.setText(bundle.getString("mExport"));
		menuExport.setMnemonic(Integer.parseInt(bundle.getString("mneExport")));
		itemJPEG.setText(bundle.getString("mExportJPEG"));
		itemJPEG.setMnemonic(Integer.parseInt(bundle.getString("mneExportJPEG")));
		itemPDF.setText(bundle.getString("mExportPDF"));
		itemPDF.setMnemonic(Integer.parseInt(bundle.getString("mneExportPDF")));
		itemPS.setText(bundle.getString("mExportPS"));
		itemPS.setMnemonic(Integer.parseInt(bundle.getString("mneExportPS")));
		itemXML.setText(bundle.getString("mExportXML"));
		itemXML.setMnemonic(Integer.parseInt(bundle.getString("mneExportXML")));
		itemExit.setText(bundle.getString("mExit"));
		itemExit.setMnemonic(Integer.parseInt(bundle.getString("mneExit")));
		
		menuEdit.setMnemonic(Integer.parseInt(bundle.getString("mneEdit")));
		menuEdit.setText(bundle.getString("mEdit"));
		itemUndo.setMnemonic(Integer.parseInt(bundle.getString("mneUndo")));
		itemUndo.setText(bundle.getString("mUndo"));
		itemRedo.setMnemonic(Integer.parseInt(bundle.getString("mneRedo")));
		itemRedo.setText(bundle.getString("mRedo"));
		itemCut.setMnemonic(Integer.parseInt(bundle.getString("mneCut")));
		itemCut.setText(bundle.getString("mCut"));
		itemCopy.setMnemonic(Integer.parseInt(bundle.getString("mneCopy")));
		itemCopy.setText(bundle.getString("mCopy"));
		itemPaste.setMnemonic(Integer.parseInt(bundle.getString("mnePaste")));
		itemPaste.setText(bundle.getString("mPaste"));
		itemSelectAll.setMnemonic(Integer.parseInt(bundle.getString("mneSelectAll")));
		itemSelectAll.setText(bundle.getString("mSelectAll"));
		itemDelete.setMnemonic(Integer.parseInt(bundle.getString("mneDelete")));
		itemDelete.setText(bundle.getString("mDelete"));
		
		menuView.setMnemonic(Integer.parseInt(bundle.getString("mneView")));
		menuView.setText(bundle.getString("mView"));
		itemWindow.setMnemonic(Integer.parseInt(bundle.getString("mneZWindow")));
		itemWindow.setText(bundle.getString("mZWindow"));
		itemZoomIn.setMnemonic(Integer.parseInt(bundle.getString("mneZIn")));
		itemZoomIn.setText(bundle.getString("mZIn"));
		itemZoomOut.setMnemonic(Integer.parseInt(bundle.getString("mneZOut")));
		itemZoomOut.setText(bundle.getString("mZOut"));
		itemAll.setMnemonic(Integer.parseInt(bundle.getString("mneZAll")));
		itemAll.setText(bundle.getString("mZAll"));
		itemExtents.setMnemonic(Integer.parseInt(bundle.getString("mneZExtents")));
		itemExtents.setText(bundle.getString("mZExtents"));
		itemLastZoom.setMnemonic(Integer.parseInt(bundle.getString("mneZLast")));
		itemLastZoom.setText(bundle.getString("mZLast"));
		menuZoom.setMnemonic(Integer.parseInt(bundle.getString("mneZoom")));
		menuZoom.setText(bundle.getString("mZoom"));
		itemRedraw.setMnemonic(Integer.parseInt(bundle.getString("mneRedraw")));
		itemRedraw.setText(bundle.getString("mRedraw"));
		
		itemViewGlobalAxis.setMnemonic(Integer.parseInt(bundle.getString("mneViewGlobalAxis")));
		itemViewGlobalAxis.setText(bundle.getString("mViewGlobalAxis"));
		itemViewLocalAxis.setMnemonic(Integer.parseInt(bundle.getString("mneViewLocalAxis")));
		itemViewLocalAxis.setText(bundle.getString("mViewLocalAxis"));
		itemViewNodeLabel.setMnemonic(Integer.parseInt(bundle.getString("mneViewNodeLabels")));
		itemViewNodeLabel.setText(bundle.getString("mViewNodeLabels"));
		
		menuDraw.setMnemonic(Integer.parseInt(bundle.getString("mneDraw")));
		menuDraw.setText(bundle.getString("mDraw"));
		itemPoint.setMnemonic(Integer.parseInt(bundle.getString("mnePoint")));
		itemPoint.setText(bundle.getString("mPoint"));
		itemLine.setMnemonic(Integer.parseInt(bundle.getString("mneLine")));
		itemLine.setText(bundle.getString("mLine"));
		itemPolyline.setMnemonic(Integer.parseInt(bundle.getString("mnePolyline")));
		itemPolyline.setText(bundle.getString("mPolyline"));
		itemQuad.setMnemonic(Integer.parseInt(bundle.getString("mneQuadraticCurve")));
		itemQuad.setText(bundle.getString("mQuadraticCurve"));
		itemCubic.setMnemonic(Integer.parseInt(bundle.getString("mneCubicCurve")));
		itemCubic.setText(bundle.getString("mCubicCurve"));
		
		menuPartition.setMnemonic(Integer.parseInt(bundle.getString("mneMeshing")));
		menuPartition.setText(bundle.getString("mMeshing"));
		itemPartition.setMnemonic(Integer.parseInt(bundle.getString("mnePartition")));
		itemPartition.setText(bundle.getString("mPartition"));
		itemPartitionAll.setMnemonic(Integer.parseInt(bundle.getString("mnePartitionAll")));
		itemPartitionAll.setText(bundle.getString("mPartitionAll"));
		
		menuRegion.setMnemonic(Integer.parseInt(bundle.getString("mneSubregions")));
		menuRegion.setText(bundle.getString("mSubregions"));
		itemMakeCurve.setMnemonic(Integer.parseInt(bundle.getString("mneMakeCurve")));
		itemMakeCurve.setText(bundle.getString("mMakeCurve"));
		menuMakeRegion.setMnemonic(Integer.parseInt(bundle.getString("mneMakeRegion")));
		menuMakeRegion.setText(bundle.getString("mMakeRegion"));
		itemMakeLofting.setMnemonic(Integer.parseInt(bundle.getString("mneLofting")));
		itemMakeLofting.setText(bundle.getString("mLofting"));
		itemMakeTrilinear.setMnemonic(Integer.parseInt(bundle.getString("mneTrilinear")));
		itemMakeTrilinear.setText(bundle.getString("mTrilinear"));
		itemMakeBilinear.setMnemonic(Integer.parseInt(bundle.getString("mneBilinear")));
		itemMakeBilinear.setText(bundle.getString("mBilinear"));
		itemSetFrame.setMnemonic(Integer.parseInt(bundle.getString("mneSetFrame")));
		itemSetFrame.setText(bundle.getString("mSetFrame"));
		
		menuGeneration.setMnemonic(Integer.parseInt(bundle.getString("mneMesh")));
		menuGeneration.setText(bundle.getString("mMesh"));
		itemMesh.setMnemonic(Integer.parseInt(bundle.getString("mneGeneration")));
		itemMesh.setText(bundle.getString("mGeneration"));
		itemInquiry.setMnemonic(Integer.parseInt(bundle.getString("mneInquiry")));
		itemInquiry.setText(bundle.getString("mInquiry"));
		
		menuAttributes.setMnemonic(Integer.parseInt(bundle.getString("mneAttributes")));
		menuAttributes.setText(bundle.getString("mAttributes"));
		itemNAngle.setMnemonic(Integer.parseInt(bundle.getString("mneAngle")));
		itemNAngle.setText(bundle.getString("mAngle"));
		itemNRestraints.setMnemonic(Integer.parseInt(bundle.getString("mneRestraints")));
		itemNRestraints.setText(bundle.getString("mRestraints"));
		itemNForces.setMnemonic(Integer.parseInt(bundle.getString("mneForces")));
		itemNForces.setText(bundle.getString("mForces"));
		itemNPreDisplacements.setMnemonic(Integer.parseInt(bundle.getString("mnePreDisplacements")));
		itemNPreDisplacements.setText(bundle.getString("mPreDisplacements"));
		itemNSpring.setMnemonic(Integer.parseInt(bundle.getString("mneSpring")));
		itemNSpring.setText(bundle.getString("mSpring"));
		itemEAnalysis.setMnemonic(Integer.parseInt(bundle.getString("mneAnalysisModel")));
		itemEAnalysis.setText(bundle.getString("mAnalysisModel"));
		itemEMaterial.setMnemonic(Integer.parseInt(bundle.getString("mneMaterial")));
		itemEMaterial.setText(bundle.getString("mMaterial"));
		itemECrossSection.setMnemonic(Integer.parseInt(bundle.getString("mneCrossSection")));
		itemECrossSection.setText(bundle.getString("mCrossSection"));
		itemECForces.setMnemonic(Integer.parseInt(bundle.getString("mneConcForces")));
		itemECForces.setText(bundle.getString("mConcForces"));
		itemEDForces.setMnemonic(Integer.parseInt(bundle.getString("mneDistForces")));
		itemEDForces.setText(bundle.getString("mDistForces"));
		itemETempChanges.setMnemonic(Integer.parseInt(bundle.getString("mneTempChanges")));
		itemETempChanges.setText(bundle.getString("mTempChanges"));
		itemELiberations.setMnemonic(Integer.parseInt(bundle.getString("mneLiberations")));
		itemELiberations.setText(bundle.getString("mLiberations"));
		itemEPreStrains.setMnemonic(Integer.parseInt(bundle.getString("mnePreStrains")));
		itemEPreStrains.setText(bundle.getString("mPreStrains"));
		itemEIniEqNForce.setMnemonic(Integer.parseInt(bundle.getString("mneIniEqNodForces")));
		itemEIniEqNForce.setText(bundle.getString("mIniEqNodForces"));
		itemElmGaussPoint.setMnemonic(Integer.parseInt(bundle.getString("mneGaussPoint")));
		itemElmGaussPoint.setText(bundle.getString("mGaussPoint"));
		itemEElasticConnections.setMnemonic(Integer.parseInt(bundle.getString("mneElasticConnections")));
		itemEElasticConnections.setText(bundle.getString("mElasticConnections"));
		menuNode.setMnemonic(Integer.parseInt(bundle.getString("mneNodalAttributes")));
		menuNode.setText(bundle.getString("mNodalAttributes"));
		menuElm.setMnemonic(Integer.parseInt(bundle.getString("mneElementAttributes")));
		menuElm.setText(bundle.getString("mElementAttributes"));
		
		menuSettings.setMnemonic(Integer.parseInt(bundle.getString("mneSettings")));
		menuSettings.setText(bundle.getString("mSettings"));
		itemSettings.setMnemonic(Integer.parseInt(bundle.getString("mneSettings")));
		itemSettings.setText(bundle.getString("mSettings"));
		itemGenSettings.setMnemonic(Integer.parseInt(bundle.getString("mneGeneralS")));
		itemGenSettings.setText(bundle.getString("mGeneralS"));
		itemLimSettings.setMnemonic(Integer.parseInt(bundle.getString("mneLimitsS")));
		itemLimSettings.setText(bundle.getString("mLimitsS"));
		itemGridSettings.setMnemonic(Integer.parseInt(bundle.getString("mneGridS")));
		itemGridSettings.setText(bundle.getString("mGridS"));
		itemScaSettings.setMnemonic(Integer.parseInt(bundle.getString("mneScalesS")));
		itemScaSettings.setText(bundle.getString("mScalesS"));
		itemAttSettings.setMnemonic(Integer.parseInt(bundle.getString("mneAttributesColorsS")));
		itemAttSettings.setText(bundle.getString("mAttributesColorsS"));
		itemDiaSettings.setMnemonic(Integer.parseInt(bundle.getString("mneDiagramsColorsS")));
		itemDiaSettings.setText(bundle.getString("mDiagramsColorsS"));
		
		menuProcessor.setMnemonic(Integer.parseInt(bundle.getString("mneProcessor")));
		menuProcessor.setText(bundle.getString("mProcessor"));
		menuProcInteractive.setMnemonic(Integer.parseInt(bundle.getString("mneInteractive")));
		menuProcInteractive.setText(bundle.getString("mInteractive"));
		menuProcAutomatic.setMnemonic(Integer.parseInt(bundle.getString("mneAutomatic")));
		menuProcAutomatic.setText(bundle.getString("mAutomatic"));
		itemAutoCheckData.setMnemonic(Integer.parseInt(bundle.getString("mneCheckData")));
		itemAutoCheckData.setText(bundle.getString("mCheckData"));
		itemAutoAnalyseModel.setMnemonic(Integer.parseInt(bundle.getString("mneAnalyseModel")));
		itemAutoAnalyseModel.setText(bundle.getString("mAnalyseModel"));
		
		menuReport.setMnemonic(Integer.parseInt(bundle.getString("mneReport")));
		menuReport.setText(bundle.getString("mReport"));
		itemReport.setMnemonic(Integer.parseInt(bundle.getString("mneViewReport")));
		itemReport.setText(bundle.getString("mViewReport"));
		
		//Toolbar
		newB.setToolTipText(bundle.getString("tNew"));
		open.setToolTipText(bundle.getString("tOpen"));
		save.setToolTipText(bundle.getString("tSave"));
		saveAs.setToolTipText(bundle.getString("tSaveAs"));
		print.setToolTipText(bundle.getString("tPrint"));
		zoom.setToolTipText(bundle.getString("tZWindow"));
		zoomIn.setToolTipText(bundle.getString("tZIn"));
		zoomOut.setToolTipText(bundle.getString("tZOut"));
		zoomAll.setToolTipText(bundle.getString("tZAll"));
		fit.setToolTipText(bundle.getString("tZExtents"));
		zoomPrevious.setToolTipText(bundle.getString("tZLast"));
		redraw.setToolTipText(bundle.getString("tRedraw"));
		undo.setToolTipText(bundle.getString("tUndo"));
		redo.setToolTipText(bundle.getString("tRedo"));
		cut.setToolTipText(bundle.getString("tCut"));
		copy.setToolTipText(bundle.getString("tCopy"));
		paste.setToolTipText(bundle.getString("tPaste"));
		delete.setToolTipText(bundle.getString("tDelete"));
		point.setToolTipText(bundle.getString("tPoint"));
		line.setToolTipText(bundle.getString("tLine"));
		polyline.setToolTipText(bundle.getString("tPolyline"));
		quad.setToolTipText(bundle.getString("tQuadraticCurve"));
		cubic.setToolTipText(bundle.getString("tCubicCurve"));
		partPrimit.setToolTipText(bundle.getString("tPartition"));
		partAllPrimit.setToolTipText(bundle.getString("tPartitionAll"));
		mkGCurve.setToolTipText(bundle.getString("tMakeCurve"));
		mkGRegion2.setToolTipText(bundle.getString("tMakeRegion1"));
		mkGRegion3.setToolTipText(bundle.getString("tMakeRegion2"));
		mkGRegion4.setToolTipText(bundle.getString("tMakeRegion3"));
		setFrame.setToolTipText(bundle.getString("tSetFrame"));
		mesh.setToolTipText(bundle.getString("tGeneration"));
		inquiry.setToolTipText(bundle.getString("tInquiry"));
		nodeAttributes.setToolTipText(bundle.getString("tNodalAttributes"));
		nodeAngle.setToolTipText(bundle.getString("tAngle"));
		nodeRestraints.setToolTipText(bundle.getString("tRestraints"));
		nodeForces.setToolTipText(bundle.getString("tForces"));
		nodePreDisplacements.setToolTipText(bundle.getString("tPreDisplacements"));
		nodeSpring.setToolTipText(bundle.getString("tSpring"));
		elmAttributes.setToolTipText(bundle.getString("tElementAttributes"));
		elmAnalysisModel.setToolTipText(bundle.getString("tAnalysisModel"));
		elmMaterial.setToolTipText(bundle.getString("tMaterial"));
		elmCrossSection.setToolTipText(bundle.getString("tCrossSection"));
		elmCForces.setToolTipText(bundle.getString("tConcForces"));
		elmDForces.setToolTipText(bundle.getString("tDistForces"));
		elmTempChanges.setToolTipText(bundle.getString("tTempChanges"));
		elmLiberations.setToolTipText(bundle.getString("tLiberations"));
		elmPreStrains.setToolTipText(bundle.getString("tPreStrains"));
		elmIniEqNForce.setToolTipText(bundle.getString("tIniEqNodForces"));
		elmElasticConnections.setToolTipText(bundle.getString("tElasticConnections"));
		elmGaussPoint.setToolTipText(bundle.getString("tGaussPoint"));
		autoCheckData.setToolTipText(bundle.getString("tCheckData"));
		autoAnalyseModel.setToolTipText(bundle.getString("tAnalyseModel"));
		ViewReport.setToolTipText(bundle.getString("tViewReport"));
		FxDiagram.setToolTipText(bundle.getString("tFx"));
		FyDiagram.setToolTipText(bundle.getString("tFy"));
		FzDiagram.setToolTipText(bundle.getString("tFz"));
		MxDiagram.setToolTipText(bundle.getString("tMx"));
		MyDiagram.setToolTipText(bundle.getString("tMy"));
		MzDiagram.setToolTipText(bundle.getString("tMz"));
		DxDiagram.setToolTipText(bundle.getString("tDx"));
		DyDiagram.setToolTipText(bundle.getString("tDy"));
		DzDiagram.setToolTipText(bundle.getString("tDz"));
		RxDiagram.setToolTipText(bundle.getString("tRx"));
		RyDiagram.setToolTipText(bundle.getString("tRy"));
		RzDiagram.setToolTipText(bundle.getString("tRz"));
		
		//Tree
		DefaultMutableTreeNode folder = null;
        DefaultMutableTreeNode subFolder = null;
        DefaultMutableTreeNode child = null;
        
        folder = ((DefaultMutableTreeNode)top.getChildAt(0));
		folder.setUserObject(bundle.getString("treePreProcessor"));
		subFolder = ((DefaultMutableTreeNode)folder.getChildAt(0));
		subFolder.setUserObject(bundle.getString("treeGeometry"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(0));
		child.setUserObject(bundle.getString("treeShapes"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(1));
		child.setUserObject(bundle.getString("treeSubregions"));
		subFolder = ((DefaultMutableTreeNode)folder.getChildAt(1));
		subFolder.setUserObject(bundle.getString("treeMeshing"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(0));
		child.setUserObject(bundle.getString("treePartition"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(1));
		child.setUserObject(bundle.getString("treeGeneration"));
		subFolder = ((DefaultMutableTreeNode)folder.getChildAt(2));
		subFolder.setUserObject(bundle.getString("treeAttributes"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(0));
		child.setUserObject(bundle.getString("treeGlobalAnalysisModel"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(1));
		child.setUserObject(bundle.getString("treeMaterial"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(2));
		child.setUserObject(bundle.getString("treeCrossSection"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(3));
		child.setUserObject(bundle.getString("treeNodalAttributes"));
		child = ((DefaultMutableTreeNode)subFolder.getChildAt(4));
		child.setUserObject(bundle.getString("treeElementAttributes"));
		folder = ((DefaultMutableTreeNode)top.getChildAt(1));
		folder.setUserObject(bundle.getString("treeProcessor"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(0));
		child.setUserObject(bundle.getString("treeInteractive"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(1));
		child.setUserObject(bundle.getString("treeAutomatic"));
		folder = ((DefaultMutableTreeNode)top.getChildAt(2));
		folder.setUserObject(bundle.getString("treePostProcessor"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(0));
		child.setUserObject(bundle.getString("treeReactions"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(1));
		child.setUserObject(bundle.getString("treeDiagrams"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(2));
		child.setUserObject(bundle.getString("treeDeform"));
		child = ((DefaultMutableTreeNode)folder.getChildAt(3));
		child.setUserObject(bundle.getString("treeReport"));
		
		//Messages
		if (model != null) {
			if (model.getState().getActualTreeNode() == ModelState.SHAPES) {
				setMessage(bundle.getString("gmCreatePrimitives"));
			}
			if (model.getState().getActualTreeNode() == ModelState.SUBREGIONS) {
				setMessage(bundle.getString("gmSubregions"));
			}
			if (model.getState().getActualTreeNode() == ModelState.PARTITION) {
				setMessage(bundle.getString("gmPartitionPrimitives"));
			}
			if (model.getState().getActualTreeNode() == ModelState.GENERATION) {
				setMessage(bundle.getString("gmGeneration"));
			}
			if (model.getState().getActualTreeNode() == ModelState.NODAL_ATTRIBUTES) {
				setMessage(bundle.getString("gmSetNodAttributes"));
			}
			if (model.getState().getActualTreeNode() == ModelState.ELM_ATTRIBUTES) {
				setMessage(bundle.getString("gmSetElmAttributes"));
			}
			if (model.getState().getActualTreeNode() == ModelState.PROC_AUTOMATIC) {
				setMessage(bundle.getString("gmAutomaticProcessor"));
			}
			if (model.getState().getActualTreeNode() == ModelState.PROC_INTERACTIVE) {
				setMessage(bundle.getString("gmInteractiveProcessor"));
			}
			if (model.getState().getActualTreeNode() == ModelState.REACTIONS) {
				setMessage(bundle.getString("gmReactions"));
			}
			if (model.getState().getActualTreeNode() == ModelState.DIAGRAMS) {
				setMessage(bundle.getString("gmDiagrams"));
			}
			if (model.getState().getActualTreeNode() == ModelState.DEFORM) {
				setMessage(bundle.getString("gmDeform"));
			}
			if (model.getState().getActualTreeNode() == ModelState.REPORT) {
				setMessage(bundle.getString("gmReport"));
			}
		}
	}
//*****************************************************************************
}
